From c723573dcb91a2e46dddb1aa4379c79b3d648e5e 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 | 13 +++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/diaspora_federation/entities/comment.rb b/lib/diaspora_federation/entities/comment.rb index f271b1da..6953c229 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..22ad9453 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(: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) } } @@ -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