diff --git a/app/models/user.rb b/app/models/user.rb index f608ee848..b187a9ea3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -394,8 +394,8 @@ class User < ActiveRecord::Base update_profile( self.profile.from_omniauth_hash( user_info ) ) end - def deliver_profile_update - Diaspora::Federation::Dispatcher.defer_dispatch(self, profile) + def deliver_profile_update(opts={}) + Diaspora::Federation::Dispatcher.defer_dispatch(self, profile, opts) end def basic_profile_present? diff --git a/app/models/user/connecting.rb b/app/models/user/connecting.rb index 643aff303..0781745f4 100644 --- a/app/models/user/connecting.rb +++ b/app/models/user/connecting.rb @@ -19,12 +19,12 @@ class User if needs_dispatch Diaspora::Federation::Dispatcher.defer_dispatch(self, contact) + deliver_profile_update(subscriber_ids: [person.id]) unless person.local? end Notifications::StartedSharing.where(recipient_id: id, target: person.id, unread: true) .update_all(unread: false) - deliver_profile_update contact end diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index c37b92936..8b8262dd2 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -167,9 +167,17 @@ describe User::Connecting, type: :model do alice.share_with(eve.person, aspect2) end - it "posts profile" do + it "delivers profile for remote persons" do allow(Diaspora::Federation::Dispatcher).to receive(:defer_dispatch) - expect(Diaspora::Federation::Dispatcher).to receive(:defer_dispatch).with(alice, alice.profile) + expect(Diaspora::Federation::Dispatcher) + .to receive(:defer_dispatch).with(alice, alice.profile, subscriber_ids: [remote_raphael.id]) + + alice.share_with(remote_raphael, alice.aspects.first) + end + + it "does not deliver profile for remote persons" do + allow(Diaspora::Federation::Dispatcher).to receive(:defer_dispatch) + expect(Diaspora::Federation::Dispatcher).not_to receive(:defer_dispatch).with(alice, alice.profile, anything) alice.share_with(eve.person, alice.aspects.first) end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index dcd5ff477..8ba7a391e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -494,12 +494,12 @@ describe User, :type => :model do it "dispatches the profile when tags are set" do @params = {tag_string: '#what #hey'} - expect(Diaspora::Federation::Dispatcher).to receive(:defer_dispatch).with(alice, alice.profile) + expect(Diaspora::Federation::Dispatcher).to receive(:defer_dispatch).with(alice, alice.profile, {}) expect(alice.update_profile(@params)).to be true end it "sends a profile to their contacts" do - expect(Diaspora::Federation::Dispatcher).to receive(:defer_dispatch).with(alice, alice.profile) + expect(Diaspora::Federation::Dispatcher).to receive(:defer_dispatch).with(alice, alice.profile, {}) expect(alice.update_profile(@params)).to be true end