diff --git a/app/models/jobs/notify_local_users.rb b/app/models/jobs/notify_local_users.rb index 791b3f628..17f8c6409 100644 --- a/app/models/jobs/notify_local_users.rb +++ b/app/models/jobs/notify_local_users.rb @@ -9,18 +9,12 @@ module Jobs require File.join(Rails.root, 'app/models/notification') def self.perform(user_ids, object_klass, object_id, person_id) - object = object_klass.constantize.find_by_id(object_id) - - #hax - return if (object.author.diaspora_handle == 'diasporahq@joindiaspora.com' || (object.respond_to?(:relayable?) && object.parent.author.diaspora_handle == 'diasporahq@joindiaspora.com')) - #end hax - - #this is really terrible - users = User.where(:id => user_ids) + users = object.participant_users person = Person.find_by_id(person_id) - - users.each{|user| Notification.notify(user, object, person) } + users.each do |user| + Notification.notify(user, object, person) + end end end end diff --git a/lib/diaspora/relayable.rb b/lib/diaspora/relayable.rb index b7d9a7aa5..c58d0affa 100644 --- a/lib/diaspora/relayable.rb +++ b/lib/diaspora/relayable.rb @@ -50,6 +50,10 @@ module Diaspora self.parent.participants end + def participant_users + self.parent.participant_users + end + def receive(user, person=nil) comment_or_like = self.class.where(:guid => self.guid).first || self diff --git a/lib/diaspora/shareable.rb b/lib/diaspora/shareable.rb index 4ffd09b19..d6e13dee9 100644 --- a/lib/diaspora/shareable.rb +++ b/lib/diaspora/shareable.rb @@ -123,6 +123,13 @@ module Diaspora end.call end + def participant_users + @participant_users ||= lambda do + user_ids = participants.map{|x| x.owner_id}.compact + User.where(:id => user_ids) + end.call + end + protected # @return [Shareable,void]