From 44693c100df496719f68f456e20ee377655d714b Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 16 Sep 2017 13:44:08 +0200 Subject: [PATCH] Federate banners out. --- lib/pleroma/user.ex | 7 +++++++ lib/pleroma/web/ostatus/user_representer.ex | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 39d8cca76..a04bbe276 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -34,6 +34,13 @@ def avatar_url(user) do end end + def banner_url(user) do + case user.info["banner"] do + %{"url" => [%{"href" => href} | _]} -> href + _ -> nil + end + end + def ap_id(%User{nickname: nickname}) do "#{Web.base_url}/users/#{nickname}" end diff --git a/lib/pleroma/web/ostatus/user_representer.ex b/lib/pleroma/web/ostatus/user_representer.ex index 273d7524a..14f78a4ed 100644 --- a/lib/pleroma/web/ostatus/user_representer.ex +++ b/lib/pleroma/web/ostatus/user_representer.ex @@ -6,6 +6,12 @@ def to_simple_form(user) do name = to_charlist(user.name) bio = to_charlist(user.bio) avatar_url = to_charlist(User.avatar_url(user)) + banner = if banner_url = User.banner_url(user) do + [{:link, [rel: 'header', href: banner_url], []}] + else + [] + end + [ {:id, [ap_id]}, {:"activity:object", ['http://activitystrea.ms/schema/1.0/person']}, @@ -15,6 +21,6 @@ def to_simple_form(user) do {:"poco:note", [bio]}, {:name, [nickname]}, {:link, [rel: 'avatar', href: avatar_url], []} - ] + ] ++ banner end end