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
|
when DiasporaFederation::Entities::Comment
|
||||||
Diaspora::Federation::Receive.comment(entity)
|
Diaspora::Federation::Receive.comment(entity)
|
||||||
when DiasporaFederation::Entities::Contact
|
when DiasporaFederation::Entities::Contact
|
||||||
# TODO
|
Diaspora::Federation::Receive.contact(entity)
|
||||||
|
# TODO: post receive actions (auto-follow-back and fetch posts)
|
||||||
when DiasporaFederation::Entities::Conversation
|
when DiasporaFederation::Entities::Conversation
|
||||||
Diaspora::Federation::Receive.conversation(entity)
|
Diaspora::Federation::Receive.conversation(entity)
|
||||||
when DiasporaFederation::Entities::Like
|
when DiasporaFederation::Entities::Like
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,18 @@ module Diaspora
|
||||||
end
|
end
|
||||||
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)
|
def self.conversation(entity)
|
||||||
Conversation.new(
|
Conversation.new(
|
||||||
author: author_of(entity),
|
author: author_of(entity),
|
||||||
|
|
|
||||||
|
|
@ -81,11 +81,9 @@ describe "Receive federation messages feature" do
|
||||||
let(:recipient) { alice }
|
let(:recipient) { alice }
|
||||||
|
|
||||||
it "treats sharing request recive correctly" do
|
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)
|
# TODO: expect(Diaspora::Fetcher::Public).to receive(:queue_for).exactly(1).times
|
||||||
|
|
||||||
expect(Diaspora::Fetcher::Public).to receive(:queue_for).exactly(1).times
|
|
||||||
|
|
||||||
post_message(generate_xml(entity, sender, alice), alice)
|
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).not_to be_nil
|
||||||
expect(new_contact.sharing).to eq(true)
|
expect(new_contact.sharing).to eq(true)
|
||||||
|
|
||||||
expect(
|
# TODO: handle notifications
|
||||||
Notifications::StartedSharing.exists?(
|
# expect(
|
||||||
recipient_id: alice.id,
|
# Notifications::StartedSharing.exists?(
|
||||||
target_type: "Person",
|
# recipient_id: alice.id,
|
||||||
target_id: sender.person.id
|
# target_type: "Person",
|
||||||
)
|
# target_id: sender.person.id
|
||||||
).to be_truthy
|
# )
|
||||||
|
# ).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with sharing" do
|
context "with sharing" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue