Merge branch 'develop' of ssh.gitgud.io:lambadalambda/pleroma into feature/unfollow...
[akkoma] / lib / pleroma / web / ostatus / activity_representer.ex
1 defmodule Pleroma.Web.OStatus.ActivityRepresenter do
2 def to_simple_form(%{data: %{"object" => %{"type" => "Note"}}} = activity, user) do
3 h = fn(str) -> [to_charlist(str)] end
4
5 updated_at = activity.updated_at
6 |> NaiveDateTime.to_iso8601
7 inserted_at = activity.inserted_at
8 |> NaiveDateTime.to_iso8601
9
10 attachments = Enum.map(activity.data["object"]["attachment"] || [], fn(attachment) ->
11 url = hd(attachment["url"])
12 {:link, [rel: 'enclosure', href: to_charlist(url["href"]), type: to_charlist(url["mediaType"])], []}
13 end)
14
15 [
16 {:"activity:object-type", ['http://activitystrea.ms/schema/1.0/note']},
17 {:"activity:verb", ['http://activitystrea.ms/schema/1.0/post']},
18 {:id, h.(activity.data["object"]["id"])},
19 {:title, ['New note by #{user.nickname}']},
20 {:content, [type: 'html'], h.(activity.data["object"]["content"])},
21 {:published, h.(inserted_at)},
22 {:updated, h.(updated_at)}
23 ] ++ attachments
24 end
25
26 def to_simple_form(_,_), do: nil
27 end