update profile
This commit is contained in:
parent
4fb34139b0
commit
f3466bcfd6
4 changed files with 25 additions and 5 deletions
|
|
@ -116,7 +116,7 @@ DiasporaFederation.configure do |config|
|
||||||
when DiasporaFederation::Entities::PollParticipation
|
when DiasporaFederation::Entities::PollParticipation
|
||||||
Diaspora::Federation::Receive.poll_participation(entity)
|
Diaspora::Federation::Receive.poll_participation(entity)
|
||||||
when DiasporaFederation::Entities::Profile
|
when DiasporaFederation::Entities::Profile
|
||||||
# TODO: update profile
|
Diaspora::Federation::Receive.profile(entity)
|
||||||
when DiasporaFederation::Entities::Reshare
|
when DiasporaFederation::Entities::Reshare
|
||||||
Diaspora::Federation::Receive.reshare(entity)
|
Diaspora::Federation::Receive.reshare(entity)
|
||||||
when DiasporaFederation::Entities::StatusMessage
|
when DiasporaFederation::Entities::StatusMessage
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ module Diaspora
|
||||||
|
|
||||||
def self.profile(profile)
|
def self.profile(profile)
|
||||||
DiasporaFederation::Entities::Profile.new(
|
DiasporaFederation::Entities::Profile.new(
|
||||||
diaspora_id: profile.diaspora_handle,
|
author: profile.diaspora_handle,
|
||||||
first_name: profile.first_name,
|
first_name: profile.first_name,
|
||||||
last_name: profile.last_name,
|
last_name: profile.last_name,
|
||||||
image_url: profile.image_url,
|
image_url: profile.image_url,
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,25 @@ module Diaspora
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.profile(entity)
|
||||||
|
author_of(entity).profile.tap do |profile|
|
||||||
|
profile.update_attributes(
|
||||||
|
first_name: entity.first_name,
|
||||||
|
last_name: entity.last_name,
|
||||||
|
image_url: entity.image_url,
|
||||||
|
image_url_medium: entity.image_url_medium,
|
||||||
|
image_url_small: entity.image_url_small,
|
||||||
|
birthday: entity.birthday,
|
||||||
|
gender: entity.gender,
|
||||||
|
bio: entity.bio,
|
||||||
|
location: entity.location,
|
||||||
|
searchable: entity.searchable,
|
||||||
|
nsfw: entity.nsfw,
|
||||||
|
tag_string: entity.tag_string
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.reshare(entity)
|
def self.reshare(entity)
|
||||||
Reshare.new(
|
Reshare.new(
|
||||||
author: author_of(entity),
|
author: author_of(entity),
|
||||||
|
|
|
||||||
|
|
@ -112,12 +112,13 @@ describe "Receive federation messages feature" do
|
||||||
it_behaves_like "messages which can't be send without sharing"
|
it_behaves_like "messages which can't be send without sharing"
|
||||||
|
|
||||||
it "treats profile receive correctly" do
|
it "treats profile receive correctly" do
|
||||||
skip("TODO: handle profile update") # TODO
|
|
||||||
|
|
||||||
entity = FactoryGirl.build(:profile_entity, author: sender_id)
|
entity = FactoryGirl.build(:profile_entity, author: sender_id)
|
||||||
post_message(generate_xml(entity, sender, alice), alice)
|
post_message(generate_xml(entity, sender, alice), alice)
|
||||||
|
|
||||||
expect(Profile.exists?(diaspora_handle: entity.diaspora_id)).to be_truthy
|
received_profile = sender.profile.reload
|
||||||
|
|
||||||
|
expect(received_profile.first_name).to eq(entity.first_name)
|
||||||
|
expect(received_profile.bio).to eq(entity.bio)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "receives conversation correctly" do
|
it "receives conversation correctly" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue