1 defmodule Pleroma.Web.OStatus.FeedRepresenter do
2 alias Pleroma.Web.OStatus
3 alias Pleroma.Web.OStatus.{UserRepresenter, ActivityRepresenter}
5 alias Pleroma.Web.MediaProxy
7 def to_simple_form(user, activities, _users) do
8 most_recent_update = (List.first(activities) || user).updated_at
9 |> NaiveDateTime.to_iso8601
11 h = fn(str) -> [to_charlist(str)] end
13 last_activity = List.last(activities)
16 |> Enum.map(fn(activity) ->
17 {:entry, ActivityRepresenter.to_simple_form(activity, user)}
19 |> Enum.filter(fn ({_, form}) -> form end)
23 xmlns: 'http://www.w3.org/2005/Atom',
24 "xmlns:thr": 'http://purl.org/syndication/thread/1.0',
25 "xmlns:activity": 'http://activitystrea.ms/spec/1.0/',
26 "xmlns:poco": 'http://portablecontacts.net/spec/1.0',
27 "xmlns:ostatus": 'http://ostatus.org/schema/1.0'
29 {:id, h.(OStatus.feed_path(user))},
30 {:title, ['#{user.nickname}\'s timeline']},
31 {:updated, h.(most_recent_update)},
32 {:logo, [to_charlist(User.avatar_url(user) |> MediaProxy.url())]},
33 {:link, [rel: 'hub', href: h.(OStatus.pubsub_path(user))], []},
34 {:link, [rel: 'salmon', href: h.(OStatus.salmon_path(user))], []},
35 {:link, [rel: 'self', href: h.(OStatus.feed_path(user)), type: 'application/atom+xml'], []},
36 {:author, UserRepresenter.to_simple_form(user)},
39 [{:link, [rel: 'next',
40 href: to_charlist(OStatus.feed_path(user)) ++ '?max_id=' ++ to_charlist(last_activity.id),
41 type: 'application/atom+xml'], []}]