Contact retraction
This commit is contained in:
parent
89fbcf7c56
commit
65ba573a3b
3 changed files with 37 additions and 12 deletions
|
|
@ -31,7 +31,11 @@ class User
|
|||
def disconnect(contact)
|
||||
logger.info "event=disconnect user=#{diaspora_handle} target=#{contact.person.diaspora_handle}"
|
||||
|
||||
# TODO: send retraction
|
||||
if contact.person.local?
|
||||
contact.person.owner.disconnected_by(contact.user.person)
|
||||
else
|
||||
Retraction.for(contact).defer_dispatch(self)
|
||||
end
|
||||
|
||||
contact.aspect_memberships.delete_all
|
||||
|
||||
|
|
|
|||
|
|
@ -200,12 +200,23 @@ module Diaspora
|
|||
end
|
||||
|
||||
def self.retraction(target)
|
||||
DiasporaFederation::Entities::Retraction.new(
|
||||
target_guid: target.is_a?(User) ? target.person.guid : target.guid,
|
||||
target_type: target.is_a?(User) ? Person.to_s : target.class.base_class.to_s,
|
||||
target: related_entity(target),
|
||||
author: target.diaspora_handle
|
||||
)
|
||||
case target
|
||||
when Contact
|
||||
author = target.user.diaspora_handle
|
||||
DiasporaFederation::Entities::Retraction.new(
|
||||
target_guid: target.user.guid,
|
||||
target_type: Person.to_s,
|
||||
target: DiasporaFederation::Entities::RelatedEntity.new(author: author, local: true),
|
||||
author: author
|
||||
)
|
||||
else
|
||||
DiasporaFederation::Entities::Retraction.new(
|
||||
target_guid: target.guid,
|
||||
target_type: target.class.base_class.to_s,
|
||||
target: related_entity(target),
|
||||
author: target.diaspora_handle
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# @deprecated
|
||||
|
|
|
|||
|
|
@ -41,8 +41,6 @@ describe User::Connecting, type: :model do
|
|||
end
|
||||
|
||||
it "removes notitications" do
|
||||
skip # TODO
|
||||
|
||||
alice.share_with(eve.person, alice.aspects.first)
|
||||
expect(Notifications::StartedSharing.where(recipient_id: eve.id).first).not_to be_nil
|
||||
eve.disconnected_by(alice.person)
|
||||
|
|
@ -79,10 +77,22 @@ describe User::Connecting, type: :model do
|
|||
expect(contact).to be_sharing
|
||||
end
|
||||
|
||||
it "dispatches a retraction" do
|
||||
skip # TODO
|
||||
it "dispatches a retraction for local person" do
|
||||
contact = bob.contact_for(eve.person)
|
||||
|
||||
bob.disconnect bob.contact_for(eve.person)
|
||||
expect(contact.person.owner).to receive(:disconnected_by).with(bob.person)
|
||||
|
||||
bob.disconnect(contact)
|
||||
end
|
||||
|
||||
it "dispatches a retraction for remote person" do
|
||||
contact = local_leia.contact_for(remote_raphael)
|
||||
retraction = double
|
||||
|
||||
expect(Retraction).to receive(:for).with(contact).and_return(retraction)
|
||||
expect(retraction).to receive(:defer_dispatch).with(local_leia)
|
||||
|
||||
local_leia.disconnect(contact)
|
||||
end
|
||||
|
||||
it "should remove the contact from all aspects they are in" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue