diff options
| author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2018-09-21 12:57:31 +0200 | 
|---|---|---|
| committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2018-09-27 20:00:46 +0200 | 
| commit | f8a0cb9c0be922a43ad9ccb6c712b4c598466573 (patch) | |
| tree | 275209afc76b609562117581d84133da768be2a4 /lib | |
| parent | a4abb124eab7a03d8670c545cdbe029baad1c5f1 (diff) | |
| download | pleroma-f8a0cb9c0be922a43ad9ccb6c712b4c598466573.tar.gz pleroma-f8a0cb9c0be922a43ad9ccb6c712b4c598466573.zip | |
[Pleroma.Web.ActivityPub.Transmogrifier]: fix when attachment contain is just a Map [kroeg]
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/pleroma/web/activity_pub/transmogrifier.ex | 17 | 
1 files changed, 15 insertions, 2 deletions
| diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 3af3efbb3..8677bc208 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -139,9 +139,9 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do      |> Map.put("conversation", context)    end -  def fix_attachments(object) do +  def fix_attachments(%{"attachment" => attachment} = object) when is_list(attachment) do      attachments = -      (object["attachment"] || []) +      attachment        |> Enum.map(fn data ->          url = [%{"type" => "Link", "mediaType" => data["mediaType"], "href" => data["url"]}]          Map.put(data, "url", url) @@ -151,6 +151,19 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do      |> Map.put("attachment", attachments)    end +  def fix_attachments(%{"attachment" => attachment} = object) when is_map(attachment) do +    attachment = +      Map.put(attachment, "url", [ +        %{"type" => "Link", "mediaType" => attachment["mediaType"], "href" => attachment["url"]} +      ]) + +    Map.put(object, "attachment", attachment) +  end + +  def fix_attachments(object) do +    object +  end +    def fix_emoji(object) do      tags = object["tag"] || []      emoji = tags |> Enum.filter(fn data -> data["type"] == "Emoji" and data["icon"] end) | 
