send the profile to remote persons on start shareing with them

This commit is contained in:
Benjamin Neff 2016-06-14 18:08:14 +02:00
parent c15babdc9f
commit 0f6e0b7288
4 changed files with 15 additions and 7 deletions

View file

@ -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?

View file

@ -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

View file

@ -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

View file

@ -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