diff --git a/lib/diaspora/relayable.rb b/lib/diaspora/relayable.rb index 476ae7649845ac0060221bec35eaa1d08ffb55ea..43a4c44c2a1bbc3d3896629b80a9d1b3bdfbc4ac 100644 --- a/lib/diaspora/relayable.rb +++ b/lib/diaspora/relayable.rb @@ -13,6 +13,10 @@ module Diaspora xml_attr :author_signature end end + + def relayable + true + end def parent_guid self.parent.guid diff --git a/lib/postzord/dispatch.rb b/lib/postzord/dispatch.rb index 65369d9e4bc610c7a1deb1e0c5da2704ca2b36cf..4b383303271bf6cd44546b95e991f4ca1e114066 100644 --- a/lib/postzord/dispatch.rb +++ b/lib/postzord/dispatch.rb @@ -22,7 +22,7 @@ class Postzord::Dispatch unless @subscribers == nil remote_people, local_people = @subscribers.partition{ |person| person.owner_id.nil? } - if @object.is_a?(Comment) && @sender.owns?(@object.post) + if @object.respond_to?(:relayable) && @sender.owns?(@object.parent) user_ids = [*local_people].map{|x| x.owner_id } local_users = User.where(:id => user_ids) self.notify_users(local_users) diff --git a/lib/postzord/receiver.rb b/lib/postzord/receiver.rb index 7281729d362db67c0cc17726757707cc2d462289..c61039bf01d5e23e55f1209cd6179e6d1c89e974 100644 --- a/lib/postzord/receiver.rb +++ b/lib/postzord/receiver.rb @@ -49,9 +49,9 @@ module Postzord end def xml_author - if @object.is_a?(Comment) + if @object.respond_to?(:relayable) #if A and B are friends, and A sends B a comment from C, we delegate the validation to the owner of the post being commented on - xml_author = @user.owns?(@object.post) ? @object.diaspora_handle : @object.post.author.diaspora_handle + xml_author = @user.owns?(@object.parent) ? @object.diaspora_handle : @object.parent.author.diaspora_handle @author = Webfinger.new(@object.diaspora_handle).fetch else xml_author = @object.diaspora_handle @@ -71,7 +71,7 @@ module Postzord end # abort if we haven't received the post to a comment - if @object.is_a?(Comment) && @object.post.nil? + if @object.respond_to?(:relayable) && @object.parent.nil? Rails.logger.info("event=receive status=abort reason='received a comment but no corresponding post' recipient=#{@user_person.diaspora_handle} sender=#{@sender.diaspora_handle} payload_type=#{@object.class})") return false end