Merge branch 'develop' into feature/incoming_ostatus
[akkoma] / lib / pleroma / web / ostatus / activity_representer.ex
index 6f101109c349b3bb22a459d416c26af364e347eb..367212fe142bd662a48057c1451afbcc6ea9c70d 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']},
@@ -14,7 +19,11 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do
       {:title, ['New note by #{user.nickname}']},
       {:content, [type: 'html'], h.(activity.data["object"]["content"])},
       {:published, h.(inserted_at)},
-      {:updated, h.(updated_at)}
-    ]
+      {:updated, h.(updated_at)},
+      {:"ostatus:conversation", [], h.(activity.data["context"])},
+      {:link, [href: h.(activity.data["context"]), rel: 'ostatus:conversation'], []}
+    ] ++ attachments
   end
+
+  def to_simple_form(_,_), do: nil
 end