fix spelling and update job to use less obtrusive query
This commit is contained in:
parent
c3dc3d103b
commit
b7d0ec7564
3 changed files with 15 additions and 10 deletions
|
|
@ -9,18 +9,12 @@ module Jobs
|
||||||
require File.join(Rails.root, 'app/models/notification')
|
require File.join(Rails.root, 'app/models/notification')
|
||||||
|
|
||||||
def self.perform(user_ids, object_klass, object_id, person_id)
|
def self.perform(user_ids, object_klass, object_id, person_id)
|
||||||
|
|
||||||
object = object_klass.constantize.find_by_id(object_id)
|
object = object_klass.constantize.find_by_id(object_id)
|
||||||
|
users = object.participant_users
|
||||||
#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)
|
|
||||||
person = Person.find_by_id(person_id)
|
person = Person.find_by_id(person_id)
|
||||||
|
users.each do |user|
|
||||||
users.each{|user| Notification.notify(user, object, person) }
|
Notification.notify(user, object, person)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,10 @@ module Diaspora
|
||||||
self.parent.participants
|
self.parent.participants
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def participant_users
|
||||||
|
self.parent.participant_users
|
||||||
|
end
|
||||||
|
|
||||||
def receive(user, person=nil)
|
def receive(user, person=nil)
|
||||||
comment_or_like = self.class.where(:guid => self.guid).first || self
|
comment_or_like = self.class.where(:guid => self.guid).first || self
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,13 @@ module Diaspora
|
||||||
end.call
|
end.call
|
||||||
end
|
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
|
protected
|
||||||
|
|
||||||
# @return [Shareable,void]
|
# @return [Shareable,void]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue