Fix conflict
[akkoma] / lib / pleroma / web / ostatus / feed_representer.ex
1 defmodule Pleroma.Web.OStatus.FeedRepresenter do
2 alias Pleroma.Web.OStatus
3 alias Pleroma.Web.OStatus.{UserRepresenter, ActivityRepresenter}
4 alias Pleroma.User
5 alias Pleroma.Web.MediaProxy
6
7 def to_simple_form(user, activities, _users) do
8 most_recent_update =
9 (List.first(activities) || user).updated_at
10 |> NaiveDateTime.to_iso8601()
11
12 h = fn str -> [to_charlist(str)] end
13
14 last_activity = List.last(activities)
15
16 entries =
17 activities
18 |> Enum.map(fn activity ->
19 {:entry, ActivityRepresenter.to_simple_form(activity, user)}
20 end)
21 |> Enum.filter(fn {_, form} -> form end)
22
23 [
24 {
25 :feed,
26 [
27 xmlns: 'http://www.w3.org/2005/Atom',
28 "xmlns:thr": 'http://purl.org/syndication/thread/1.0',
29 "xmlns:activity": 'http://activitystrea.ms/spec/1.0/',
30 "xmlns:poco": 'http://portablecontacts.net/spec/1.0',
31 "xmlns:ostatus": 'http://ostatus.org/schema/1.0'
32 ],
33 [
34 {:id, h.(OStatus.feed_path(user))},
35 {:title, ['#{user.nickname}\'s timeline']},
36 {:updated, h.(most_recent_update)},
37 {:logo, [to_charlist(User.avatar_url(user) |> MediaProxy.url())]},
38 {:link, [rel: 'hub', href: h.(OStatus.pubsub_path(user))], []},
39 {:link, [rel: 'salmon', href: h.(OStatus.salmon_path(user))], []},
40 {:link, [rel: 'self', href: h.(OStatus.feed_path(user)), type: 'application/atom+xml'],
41 []},
42 {:author, UserRepresenter.to_simple_form(user)}
43 ] ++
44 if last_activity do
45 [
46 {:link,
47 [
48 rel: 'next',
49 href:
50 to_charlist(OStatus.feed_path(user)) ++
51 '?max_id=' ++ to_charlist(last_activity.id),
52 type: 'application/atom+xml'
53 ], []}
54 ]
55 else
56 []
57 end ++ entries
58 }
59 ]
60 end
61 end