Update
This commit is contained in:
parent
188bc08494
commit
4af88f3e1d
44 changed files with 1041 additions and 34 deletions
44
lib/nulla_web/controllers/activitypub/outbox_json.ex
Normal file
44
lib/nulla_web/controllers/activitypub/outbox_json.ex
Normal file
|
@ -0,0 +1,44 @@
|
|||
defmodule NullaWeb.ActivityPub.OutboxJSON do
|
||||
@doc """
|
||||
Renders an outbox.
|
||||
"""
|
||||
def index(actor, total) do
|
||||
Jason.OrderedObject.new(
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
id: actor.outbox,
|
||||
type: "OrderedCollection",
|
||||
totalItems: total,
|
||||
first: "#{actor.outbox}?page=true",
|
||||
last: "#{actor.outbox}?min_id=0&page=true"
|
||||
)
|
||||
end
|
||||
|
||||
def show(actor, activities, max_id, min_id) do
|
||||
Jason.OrderedObject.new(
|
||||
"@context": [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
Jason.OrderedObject.new(
|
||||
sensitive: "as:sensitive",
|
||||
Hashtag: "as:Hashtag"
|
||||
)
|
||||
],
|
||||
id: "#{actor.outbox}?page=true",
|
||||
type: "OrderedCollectionPage",
|
||||
next: "#{actor.outbox}?max_id=#{max_id}&page=true",
|
||||
prev: "#{actor.outbox}?min_id=#{min_id}&page=true",
|
||||
partOf: actor.outbox,
|
||||
orderedItems: Enum.map(activities, &data/1)
|
||||
)
|
||||
end
|
||||
|
||||
defp data(activity) do
|
||||
Jason.OrderedObject.new(
|
||||
id: activity.ap_id,
|
||||
type: activity.type,
|
||||
actor: activity.actor,
|
||||
object: activity.object,
|
||||
to: activity.to,
|
||||
cc: activity.cc
|
||||
)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue