diff --git a/app/workers/notify_local_users.rb b/app/workers/notify_local_users.rb deleted file mode 100644 index 18a15886b..000000000 --- a/app/workers/notify_local_users.rb +++ /dev/null @@ -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 diff --git a/lib/postzord/dispatcher.rb b/lib/postzord/dispatcher.rb index ceeb6c151..3677821e8 100644 --- a/lib/postzord/dispatcher.rb +++ b/lib/postzord/dispatcher.rb @@ -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] - # @return [ActiveRecord::Association, 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] 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] - def notify_local_users(local_people) - local_users = fetch_local_users(local_people) - self.notify_users(local_users) - end - - # @param services [Array] - 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 diff --git a/spec/lib/postzord/dispatcher_spec.rb b/spec/lib/postzord/dispatcher_spec.rb index a630ab1fa..33c1d9e2c 100644 --- a/spec/lib/postzord/dispatcher_spec.rb +++ b/spec/lib/postzord/dispatcher_spec.rb @@ -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