Add attachments to feed.
authorRoger Braun <roger@rogerbraun.net>
Sat, 22 Apr 2017 10:09:13 +0000 (12:09 +0200)
committerRoger Braun <roger@rogerbraun.net>
Sat, 22 Apr 2017 10:09:13 +0000 (12:09 +0200)
lib/pleroma/web/ostatus/activity_representer.ex

index 6f101109c349b3bb22a459d416c26af364e347eb..daaa4ef03f115e7e0a6bd58c7b4bf7451bfbdacd 100644 (file)
@@ -7,6 +7,11 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do
     inserted_at = activity.inserted_at
     |> NaiveDateTime.to_iso8601
 
+    attachments = Enum.map(activity.data["object"]["attachment"] || [], fn(attachment) ->
+      url = hd(attachment["url"])
+      {:link, [rel: 'enclosure', href: to_charlist(url["href"]), type: to_charlist(url["mediaType"])], []}
+    end)
+
     [
       {:"activity:object-type", ['http://activitystrea.ms/schema/1.0/note']},
       {:"activity:verb", ['http://activitystrea.ms/schema/1.0/post']},
@@ -15,6 +20,6 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do
       {:content, [type: 'html'], h.(activity.data["object"]["content"])},
       {:published, h.(inserted_at)},
       {:updated, h.(updated_at)}
-    ]
+    ] ++ attachments
   end
 end