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
|
@ -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
|
||||
|
||||
_ ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue