Skip to content

Commit

Permalink
fixes 124
Browse files Browse the repository at this point in the history
Adds the thread_parent_guid_ attribute to comment as described in the docs.
  • Loading branch information
tclaus committed Mar 29, 2022
1 parent 078f8a5 commit c723573
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 6 additions & 0 deletions lib/diaspora_federation/entities/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ class Comment < Entity
# The timestamp when the comment was edited
# @return [Time] edited time
property :edited_at, :timestamp, optional: true

#@!attribute [r] guid
# A random string of at least 16 chars pointing to a parent comment.
# @see Validation::Rule::Guid
# @return [String] parent comment guid
property :thread_parent_guid, :string, optional: true
end
end
end
13 changes: 9 additions & 4 deletions spec/lib/diaspora_federation/entities/comment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ module DiasporaFederation
describe Entities::Comment do
let(:parent) { Fabricate(:post, author: bob) }
let(:parent_entity) { Fabricate(:related_entity, author: bob.diaspora_id) }
let(:data) {
let(:parent_comment) { Fabricate(:comment)}
let(:data) {
Fabricate
.attributes_for(
:comment_entity,
author: alice.diaspora_id,
parent_guid: parent.guid,
parent: parent_entity
parent: parent_entity,
thread_parent_guid: parent_comment.guid
).tap {|hash| add_signatures(hash) }
}

Expand All @@ -22,6 +24,7 @@ module DiasporaFederation
<text>#{data[:text]}</text>
<created_at>#{data[:created_at].utc.iso8601}</created_at>
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
<thread_parent_guid>#{parent_comment.guid}</thread_parent_guid>
<author_signature>#{data[:author_signature]}</author_signature>
</comment>
XML
Expand All @@ -36,15 +39,17 @@ module DiasporaFederation
"author_signature": "#{data[:author_signature]}",
"text": "#{data[:text]}",
"created_at": "#{data[:created_at].iso8601}",
"edited_at": "#{data[:edited_at].iso8601}"
"edited_at": "#{data[:edited_at].iso8601}",
"thread_parent_guid": "#{parent_comment.guid}"
},
"property_order": [
"author",
"guid",
"parent_guid",
"text",
"created_at",
"edited_at"
"edited_at",
"thread_parent_guid"
]
}
JSON
Expand Down

0 comments on commit c723573

Please sign in to comment.