aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-06-14 16:49:28 +0000
committerrinpatch <rinpatch@sdf.org>2019-06-14 16:49:28 +0000
commit62ffc00a5d5975a75c905bc728feb71cd15a34d3 (patch)
tree8f71fe152d00b272774aeeeeb65f302f667f7a91 /lib
parent270f09dbc2cb145e5a06b72189bd1b91dd3d3a02 (diff)
parent774637a2f4505d62a2afb243b04ba283030047dc (diff)
downloadpleroma-62ffc00a5d5975a75c905bc728feb71cd15a34d3.tar.gz
Merge branch 'feature/add-background-image-to-mastoapi' into 'develop'
AccountView: Add user background. See merge request pleroma/pleroma!1280
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex8
-rw-r--r--lib/pleroma/web/mastodon_api/views/account_view.ex6
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index 84359eea6..684b03066 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -136,6 +136,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
_ -> :error
end
end)
+ |> add_if_present(params, "pleroma_background_image", :background, fn value ->
+ with %Plug.Upload{} <- value,
+ {:ok, object} <- ActivityPub.upload(value, type: :background) do
+ {:ok, object.data}
+ else
+ _ -> :error
+ end
+ end)
|> Map.put(:emoji, user_info_emojis)
info_cng = User.Info.profile_update(user.info, info_params)
diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex
index b91726b45..0ec9ecd93 100644
--- a/lib/pleroma/web/mastodon_api/views/account_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/account_view.ex
@@ -125,7 +125,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
hide_follows: user.info.hide_follows,
hide_favorites: user.info.hide_favorites,
relationship: relationship,
- skip_thread_containment: user.info.skip_thread_containment
+ skip_thread_containment: user.info.skip_thread_containment,
+ background_image: image_url(user.info.background) |> MediaProxy.url()
}
}
|> maybe_put_role(user, opts[:for])
@@ -182,4 +183,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
end
defp maybe_put_notification_settings(data, _, _), do: data
+
+ defp image_url(%{"url" => [%{"href" => href} | _]}), do: href
+ defp image_url(_), do: nil
end