Update
This commit is contained in:
parent
188bc08494
commit
4af88f3e1d
44 changed files with 1041 additions and 34 deletions
50
lib/nulla_web/controllers/activitypub/note_json.ex
Normal file
50
lib/nulla_web/controllers/activitypub/note_json.ex
Normal file
|
@ -0,0 +1,50 @@
|
|||
defmodule NullaWeb.ActivityPub.NoteJSON do
|
||||
alias Nulla.Notes.Note
|
||||
|
||||
@doc """
|
||||
Renders a single note.
|
||||
"""
|
||||
def show(note) do
|
||||
data(note)
|
||||
end
|
||||
|
||||
defp data(%Note{} = note) do
|
||||
attachment =
|
||||
case note.media_attachments do
|
||||
[] ->
|
||||
[]
|
||||
|
||||
attachments ->
|
||||
[
|
||||
attachment:
|
||||
Enum.map(attachments, fn att ->
|
||||
Jason.OrderedObject.new(
|
||||
type: "Document",
|
||||
mediaType: att.mime_type,
|
||||
url: "https://#{note.actor.domain}/files/#{att.file}"
|
||||
)
|
||||
end)
|
||||
]
|
||||
end
|
||||
|
||||
Jason.OrderedObject.new(
|
||||
"@context": [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
Jason.OrderedObject.new(sensitive: "as:sensitive")
|
||||
],
|
||||
id: "#{note.actor.ap_id}/notes/#{note.id}",
|
||||
type: "Note",
|
||||
summary: nil,
|
||||
inReplyTo: note.inReplyTo,
|
||||
published: note.published,
|
||||
url: note.url,
|
||||
attributedTo: note.actor.ap_id,
|
||||
to: note.to,
|
||||
cc: note.cc,
|
||||
sensitive: note.sensitive,
|
||||
content: note.content,
|
||||
contentMap: Jason.OrderedObject.new("#{note.language}": note.content),
|
||||
attachment: attachment
|
||||
)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue