update profile

This commit is contained in:
Benjamin Neff 2016-05-07 17:42:35 +02:00
parent 4fb34139b0
commit f3466bcfd6
4 changed files with 25 additions and 5 deletions

View file

@ -116,7 +116,7 @@ DiasporaFederation.configure do |config|
when DiasporaFederation::Entities::PollParticipation
Diaspora::Federation::Receive.poll_participation(entity)
when DiasporaFederation::Entities::Profile
# TODO: update profile
Diaspora::Federation::Receive.profile(entity)
when DiasporaFederation::Entities::Reshare
Diaspora::Federation::Receive.reshare(entity)
when DiasporaFederation::Entities::StatusMessage

View file

@ -62,7 +62,7 @@ module Diaspora
def self.profile(profile)
DiasporaFederation::Entities::Profile.new(
diaspora_id: profile.diaspora_handle,
author: profile.diaspora_handle,
first_name: profile.first_name,
last_name: profile.last_name,
image_url: profile.image_url,

View file

@ -84,6 +84,25 @@ module Diaspora
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)
Reshare.new(
author: author_of(entity),

View file

@ -112,12 +112,13 @@ describe "Receive federation messages feature" do
it_behaves_like "messages which can't be send without sharing"
it "treats profile receive correctly" do
skip("TODO: handle profile update") # TODO
entity = FactoryGirl.build(:profile_entity, author: sender_id)
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
it "receives conversation correctly" do