From b6dd7ca833865742ed565958f419b537edd74f3f Mon Sep 17 00:00:00 2001 From: tclaus Date: Tue, 29 Mar 2022 19:39:23 +0200 Subject: [PATCH] fixes 124 Adds the thread_parent_guid_ attribute to comment as described in the docs. --- lib/diaspora_federation/entities/comment.rb | 6 ++++++ .../diaspora_federation/entities/comment_spec.rb | 15 ++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/diaspora_federation/entities/comment.rb b/lib/diaspora_federation/entities/comment.rb index f271b1da..a81bbc27 100644 --- a/lib/diaspora_federation/entities/comment.rb +++ b/lib/diaspora_federation/entities/comment.rb @@ -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 diff --git a/spec/lib/diaspora_federation/entities/comment_spec.rb b/spec/lib/diaspora_federation/entities/comment_spec.rb index 2efb00da..c2ac875c 100644 --- a/spec/lib/diaspora_federation/entities/comment_spec.rb +++ b/spec/lib/diaspora_federation/entities/comment_spec.rb @@ -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) } } @@ -22,6 +24,7 @@ module DiasporaFederation #{data[:text]} #{data[:created_at].utc.iso8601} #{data[:edited_at].utc.iso8601} + #{parent_comment.guid} #{data[:author_signature]} XML @@ -36,7 +39,8 @@ 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", @@ -44,7 +48,8 @@ module DiasporaFederation "parent_guid", "text", "created_at", - "edited_at" + "edited_at", + "thread_parent_guid" ] } JSON