handle receive contact
This commit is contained in:
parent
e0da6708f4
commit
87666eeb35
3 changed files with 24 additions and 12 deletions
|
|
@ -97,7 +97,8 @@ DiasporaFederation.configure do |config|
|
|||
when DiasporaFederation::Entities::Comment
|
||||
Diaspora::Federation::Receive.comment(entity)
|
||||
when DiasporaFederation::Entities::Contact
|
||||
# TODO
|
||||
Diaspora::Federation::Receive.contact(entity)
|
||||
# TODO: post receive actions (auto-follow-back and fetch posts)
|
||||
when DiasporaFederation::Entities::Conversation
|
||||
Diaspora::Federation::Receive.conversation(entity)
|
||||
when DiasporaFederation::Entities::Like
|
||||
|
|
|
|||
|
|
@ -21,6 +21,18 @@ module Diaspora
|
|||
end
|
||||
end
|
||||
|
||||
def self.contact(entity)
|
||||
recipient = Person.find_by(diaspora_handle: entity.recipient).owner
|
||||
contact = recipient.contacts.find_or_initialize_by(person_id: author_of(entity).id)
|
||||
|
||||
return if contact.sharing
|
||||
|
||||
contact.tap do |contact|
|
||||
contact.sharing = true
|
||||
contact.save!
|
||||
end
|
||||
end
|
||||
|
||||
def self.conversation(entity)
|
||||
Conversation.new(
|
||||
author: author_of(entity),
|
||||
|
|
|
|||
|
|
@ -81,11 +81,9 @@ describe "Receive federation messages feature" do
|
|||
let(:recipient) { alice }
|
||||
|
||||
it "treats sharing request recive correctly" do
|
||||
skip("TODO: handle contacts") # TODO
|
||||
entity = FactoryGirl.build(:request_entity, author: sender_id, recipient: alice.diaspora_handle)
|
||||
|
||||
entity = FactoryGirl.build(:request_entity, recipient: alice.diaspora_handle)
|
||||
|
||||
expect(Diaspora::Fetcher::Public).to receive(:queue_for).exactly(1).times
|
||||
# TODO: expect(Diaspora::Fetcher::Public).to receive(:queue_for).exactly(1).times
|
||||
|
||||
post_message(generate_xml(entity, sender, alice), alice)
|
||||
|
||||
|
|
@ -94,13 +92,14 @@ describe "Receive federation messages feature" do
|
|||
expect(new_contact).not_to be_nil
|
||||
expect(new_contact.sharing).to eq(true)
|
||||
|
||||
expect(
|
||||
Notifications::StartedSharing.exists?(
|
||||
recipient_id: alice.id,
|
||||
target_type: "Person",
|
||||
target_id: sender.person.id
|
||||
)
|
||||
).to be_truthy
|
||||
# TODO: handle notifications
|
||||
# expect(
|
||||
# Notifications::StartedSharing.exists?(
|
||||
# recipient_id: alice.id,
|
||||
# target_type: "Person",
|
||||
# target_id: sender.person.id
|
||||
# )
|
||||
# ).to be_truthy
|
||||
end
|
||||
|
||||
context "with sharing" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue