Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes 124 Adding missing attribute #125

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field should also be added to the CommentValidator to validate it's a valid GUID.
And it should also be added to the comment entity in lib/diaspora_federation/schemas/federation_entities.json.

end
end
end
15 changes: 10 additions & 5 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(:parent_comment) { Fabricate(:comment) }
let(:data) {
Fabricate
.attributes_for(
:comment_entity,
author: alice.diaspora_id,
parent_guid: parent.guid,
parent: parent_entity
author: alice.diaspora_id,
parent_guid: parent.guid,
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