query = User.get_friends_query(user)
query = from(user in query, select: [:ap_id])
following = Repo.all(query)
+
total =
if !user.info.hide_follows do
length(following)
query = User.get_friends_query(user)
query = from(user in query, select: [:ap_id])
following = Repo.all(query)
+
total =
if !user.info.hide_follows do
length(following)
query = User.get_followers_query(user)
query = from(user in query, select: [:ap_id])
followers = Repo.all(query)
+
total =
if !user.info.hide_followers do
length(followers)
query = User.get_followers_query(user)
query = from(user in query, select: [:ap_id])
followers = Repo.all(query)
+
total =
if !user.info.hide_followers do
length(followers)
"id" => "#{user.ap_id}/followers",
"type" => "OrderedCollection",
"totalItems" => total,
- "first" => collection(followers, "#{user.ap_id}/followers", 1, !user.info.hide_followers, total)
+ "first" =>
+ collection(followers, "#{user.ap_id}/followers", 1, !user.info.hide_followers, total)
}
|> Map.merge(Utils.make_json_ld_header())
end
end
activities = ActivityPub.fetch_user_activities(user, nil, params)
- min_id = Enum.at(Enum.reverse(activities), 0).id
- max_id = Enum.at(activities, 0).id
- collection =
- Enum.map(activities, fn act ->
- {:ok, data} = Transmogrifier.prepare_outgoing(act.data)
- data
- end)
+ {max_id, min_id, collection} =
+ if length(activities) > 0 do
+ {
+ Enum.at(Enum.reverse(activities), 0).id,
+ Enum.at(activities, 0).id,
+ Enum.map(activities, fn act ->
+ {:ok, data} = Transmogrifier.prepare_outgoing(act.data)
+ data
+ end)
+ }
+ else
+ {
+ 0,
+ 0,
+ []
+ }
+ end
iri = "#{user.ap_id}/outbox"