Skip to content
Extraits de code Groupes Projets
Valider 9490538e rédigé par zhitomirskiyi's avatar zhitomirskiyi
Parcourir les fichiers

checking for relayable in the dispatcher and the receiver

parent 8bcf1b49
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -13,6 +13,10 @@ module Diaspora
xml_attr :author_signature
end
end
def relayable
true
end
def parent_guid
self.parent.guid
......
......@@ -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)
......
......@@ -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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter