remove NotifyLocalUsers worker
This commit is contained in:
parent
645c7bd5ad
commit
83f5662d62
3 changed files with 1 additions and 73 deletions
|
|
@ -1,19 +0,0 @@
|
|||
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
module Workers
|
||||
class NotifyLocalUsers < Base
|
||||
sidekiq_options queue: :receive_local
|
||||
|
||||
def perform(user_ids, object_klass, object_id, person_id)
|
||||
|
||||
object = object_klass.constantize.find_by_id(object_id)
|
||||
|
||||
users = User.where(:id => user_ids)
|
||||
person = Person.find_by_id(person_id)
|
||||
|
||||
# TODO: users.find_each{|user| Notification.notify(user, object, person) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -79,9 +79,7 @@ class Postzord::Dispatcher
|
|||
def post_to_subscribers
|
||||
remote_people, local_people = @subscribers.partition{ |person| person.owner_id.nil? }
|
||||
|
||||
if @object.respond_to?(:relayable?) && @sender.owns?(@object.parent)
|
||||
self.notify_local_users(local_people)
|
||||
else
|
||||
unless @object.respond_to?(:relayable?) && @sender.owns?(@object.parent)
|
||||
self.deliver_to_local(local_people)
|
||||
end
|
||||
|
||||
|
|
@ -93,14 +91,6 @@ class Postzord::Dispatcher
|
|||
@object.subscribers(@sender)
|
||||
end
|
||||
|
||||
# @param local_people [Array<People>]
|
||||
# @return [ActiveRecord::Association<User>, Array]
|
||||
def fetch_local_users(people)
|
||||
return [] if people.blank?
|
||||
user_ids = people.map{|x| x.owner_id }
|
||||
User.where(:id => user_ids)
|
||||
end
|
||||
|
||||
# @param remote_people [Array<Person>] Recipients of the post on other pods
|
||||
def deliver_to_remote(remote_people)
|
||||
return if remote_people.blank?
|
||||
|
|
@ -161,18 +151,5 @@ class Postzord::Dispatcher
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
# @param local_people [Array<People>]
|
||||
def notify_local_users(local_people)
|
||||
local_users = fetch_local_users(local_people)
|
||||
self.notify_users(local_users)
|
||||
end
|
||||
|
||||
# @param services [Array<User>]
|
||||
def notify_users(users)
|
||||
return unless users.present? && @object.respond_to?(:persisted?)
|
||||
|
||||
Workers::NotifyLocalUsers.perform_async(users.map(&:id), @object.class.to_s, @object.id, @object.author.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -118,11 +118,6 @@ describe Postzord::Dispatcher do
|
|||
expect(@mailman).to receive(:deliver_to_remote).with([@remote_raphael])
|
||||
@mailman.post
|
||||
end
|
||||
|
||||
it 'calls notify_users' do
|
||||
expect(@mailman).to receive(:notify_users).with([@local_leia])
|
||||
@mailman.post
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -142,11 +137,6 @@ describe Postzord::Dispatcher do
|
|||
expect(@mailman).to receive(:deliver_to_remote).with([@remote_raphael])
|
||||
@mailman.post
|
||||
end
|
||||
|
||||
it 'calls notify_users' do
|
||||
expect(@mailman).to receive(:notify_users).with([@local_leia])
|
||||
@mailman.post
|
||||
end
|
||||
end
|
||||
|
||||
context "local luke" do
|
||||
|
|
@ -165,11 +155,6 @@ describe Postzord::Dispatcher do
|
|||
expect(@mailman).to receive(:deliver_to_remote).with([@remote_raphael])
|
||||
@mailman.post
|
||||
end
|
||||
|
||||
it 'calls notify_users' do
|
||||
expect(@mailman).to receive(:notify_users).with([@local_leia])
|
||||
@mailman.post
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -318,21 +303,6 @@ describe Postzord::Dispatcher do
|
|||
expect(Workers::DeletePostFromService).to receive(:perform_async).with(anything, anything)
|
||||
mailman.post
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '#and_notify_local_users' do
|
||||
it 'calls notifiy_users' do
|
||||
expect(@zord).to receive(:notify_users).with([bob])
|
||||
@zord.send(:notify_local_users, [bob.person])
|
||||
end
|
||||
end
|
||||
|
||||
describe '#notify_users' do
|
||||
it 'enqueues a NotifyLocalUsers job' do
|
||||
expect(Workers::NotifyLocalUsers).to receive(:perform_async).with([bob.id], @zord.object.class.to_s, @zord.object.id, @zord.object.author.id)
|
||||
@zord.send(:notify_users, [bob])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue