Add likes and shares to activitypub note

This commit is contained in:
Mirai Kumiko 2025-07-06 15:04:27 +02:00
parent 00ecbadeca
commit 60ca00e5d8
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
4 changed files with 37 additions and 6 deletions

View file

@ -1,8 +1,10 @@
defmodule NullaWeb.ActivityPub.NoteController do
use NullaWeb, :controller
alias Nulla.Repo
alias NullaWeb.ActivityPub.NoteJSON
alias Nulla.Notes
alias Nulla.Likes
alias Nulla.Announces
alias NullaWeb.ActivityPub.NoteJSON
def show(conn, %{"username" => username, "id" => id}) do
case Integer.parse(id) do
@ -23,9 +25,12 @@ defmodule NullaWeb.ActivityPub.NoteController do
|> halt()
true ->
likes_count = length(Likes.list_likes_by(note_id: note.id))
shares_count = length(Announces.list_announces_by(note_id: note.id))
conn
|> put_resp_content_type("application/activity+json")
|> json(NoteJSON.show(note))
|> json(NoteJSON.show(note, likes_count, shares_count))
end
_ ->