1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.OStatus.FeedRepresenter do
7 alias Pleroma.Web.MediaProxy
8 alias Pleroma.Web.OStatus
9 alias Pleroma.Web.OStatus.ActivityRepresenter
10 alias Pleroma.Web.OStatus.UserRepresenter
12 def to_simple_form(user, activities, _users) do
14 (List.first(activities) || user).updated_at
15 |> NaiveDateTime.to_iso8601()
17 h = fn str -> [to_charlist(str)] end
19 last_activity = List.last(activities)
23 |> Enum.map(fn activity ->
24 {:entry, ActivityRepresenter.to_simple_form(activity, user)}
26 |> Enum.filter(fn {_, form} -> form end)
32 xmlns: 'http://www.w3.org/2005/Atom',
33 "xmlns:thr": 'http://purl.org/syndication/thread/1.0',
34 "xmlns:activity": 'http://activitystrea.ms/spec/1.0/',
35 "xmlns:poco": 'http://portablecontacts.net/spec/1.0',
36 "xmlns:ostatus": 'http://ostatus.org/schema/1.0'
39 {:id, h.(OStatus.feed_path(user))},
40 {:title, ['#{user.nickname}\'s timeline']},
41 {:updated, h.(most_recent_update)},
42 {:logo, [to_charlist(User.avatar_url(user) |> MediaProxy.url())]},
43 {:link, [rel: 'hub', href: h.(OStatus.pubsub_path(user))], []},
44 {:link, [rel: 'salmon', href: h.(OStatus.salmon_path(user))], []},
45 {:link, [rel: 'self', href: h.(OStatus.feed_path(user)), type: 'application/atom+xml'],
47 {:author, UserRepresenter.to_simple_form(user)}
55 to_charlist(OStatus.feed_path(user)) ++
56 '?max_id=' ++ to_charlist(last_activity.id),
57 type: 'application/atom+xml'