aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Vanderbauwhede <Wim.Vanderbauwhede@mail.be>2019-01-04 15:35:41 +0000
committerWim Vanderbauwhede <Wim.Vanderbauwhede@mail.be>2019-01-04 15:35:41 +0000
commit4c95545d194e8a807e9e3514ed75347d78ec0856 (patch)
treecb0e3305be8149191f28c5127f19c4adb89c3e25
parentfe2dceb66d056809d9a145773a8053ac9fb02658 (diff)
downloadpleroma-4c95545d194e8a807e9e3514ed75347d78ec0856.tar.gz
Patch to support image descriptions in Pleroma FE
-rw-r--r--lib/pleroma/web/common_api/common_api.ex2
-rw-r--r--lib/pleroma/web/common_api/utils.ex13
2 files changed, 7 insertions, 8 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index e474653ff..50074b8b0 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -90,7 +90,7 @@ defmodule Pleroma.Web.CommonAPI do
limit = Pleroma.Config.get([:instance, :limit])
with status <- String.trim(status),
- attachments <- attachments_from_ids(data["media_ids"]),
+ attachments <- attachments_from_ids(data["media_ids"], data["descriptions"]),
mentions <- Formatter.parse_mentions(status),
inReplyTo <- get_replied_to_activity(data["in_reply_to_status_id"]),
{to, cc} <- to_for_user_and_mentions(user, mentions, inReplyTo, visibility),
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex
index 51e74ac8f..5fe21fb99 100644
--- a/lib/pleroma/web/common_api/utils.ex
+++ b/lib/pleroma/web/common_api/utils.ex
@@ -1,9 +1,8 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.CommonAPI.Utils do
- require Logger
alias Calendar.Strftime
alias Comeonin.Pbkdf2
alias Pleroma.{Activity, Formatter, Object, Repo}
@@ -33,11 +32,11 @@ defmodule Pleroma.Web.CommonAPI.Utils do
def get_replied_to_activity(_), do: nil
- def attachments_from_ids(ids, descs) do
- Enum.map(ids || [], fn media_id -> do
- Logger.warn(descs[media_id])
- Repo.get(Object, media_id).data
- end
+ def attachments_from_ids(ids, descs_str) do
+ {_, descs} = Jason.decode(descs_str)
+
+ Enum.map(ids || [], fn media_id ->
+ Map.put(Repo.get(Object, media_id).data, "name", descs[media_id])
end)
end