Patch to support image descriptions in Pleroma FE
[akkoma] / lib / pleroma / web / common_api / utils.ex
index 813eb4093163fe8e8fb31f107987c79eb1e9ac82..5fe21fb99c367d5f01ccbb3d51bf42b030c375a7 100644 (file)
@@ -1,5 +1,5 @@
 # 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
@@ -32,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
 
@@ -261,5 +263,4 @@ defmodule Pleroma.Web.CommonAPI.Utils do
       }
     end)
   end
-
 end