Add likes and shares to activitypub note
This commit is contained in:
parent
00ecbadeca
commit
60ca00e5d8
4 changed files with 37 additions and 6 deletions
|
@ -4,11 +4,11 @@ defmodule NullaWeb.ActivityPub.NoteJSON do
|
|||
@doc """
|
||||
Renders a single note.
|
||||
"""
|
||||
def show(note) do
|
||||
data(note)
|
||||
def show(note, likes_count, shares_count) do
|
||||
data(note, likes_count, shares_count)
|
||||
end
|
||||
|
||||
defp data(%Note{} = note) do
|
||||
defp data(%Note{} = note, likes_count, shares_count) do
|
||||
attachment =
|
||||
case note.media_attachments do
|
||||
[] ->
|
||||
|
@ -44,7 +44,21 @@ defmodule NullaWeb.ActivityPub.NoteJSON do
|
|||
sensitive: note.sensitive,
|
||||
content: note.content,
|
||||
contentMap: Jason.OrderedObject.new("#{note.language}": note.content),
|
||||
attachment: attachment
|
||||
attachment: attachment,
|
||||
tag: note.tag,
|
||||
replies: %{},
|
||||
likes:
|
||||
Jason.OrderedObject.new(
|
||||
id: "#{note.ap_id}/likes",
|
||||
type: "Collection",
|
||||
totalItems: likes_count
|
||||
),
|
||||
shares:
|
||||
Jason.OrderedObject.new(
|
||||
id: "#{note.ap_id}/shares",
|
||||
type: "Collection",
|
||||
totalItems: shares_count
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue