X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpleroma%2Fweb%2Fcommon_api%2Futils.ex;h=5fe21fb99c367d5f01ccbb3d51bf42b030c375a7;hb=4c95545d194e8a807e9e3514ed75347d78ec0856;hp=d25fef6bce05a5b2091897cbb754e54ce47fe523;hpb=0f412cf6e68fcebda3e94b71b7f182af689748bf;p=akkoma diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index d25fef6bc..5fe21fb99 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.CommonAPI.Utils do alias Calendar.Strftime alias Comeonin.Pbkdf2 @@ -28,9 +32,11 @@ defmodule Pleroma.Web.CommonAPI.Utils do def get_replied_to_activity(_), do: nil - def attachments_from_ids(ids) do + def attachments_from_ids(ids, descs_str) do + {_, descs} = Jason.decode(descs_str) + Enum.map(ids || [], fn media_id -> - Repo.get(Object, media_id).data + Map.put(Repo.get(Object, media_id).data, "name", descs[media_id]) end) end @@ -69,12 +75,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do mentioned_users = Enum.map(mentions, fn {_, %{ap_id: ap_id}} -> ap_id end) if inReplyTo do - to = - [inReplyTo.data["actor"] | mentioned_users] - |> Enum.uniq() - |> Enum.reject(&is_nil/1) - - {to, []} + {Enum.uniq([inReplyTo.data["actor"] | mentioned_users]), []} else {mentioned_users, []} end