Add following and followers

This commit is contained in:
Mirai Kumiko 2025-06-11 15:03:21 +02:00
parent f8bedff913
commit 0b88881934
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
8 changed files with 261 additions and 4 deletions

View file

@ -4,6 +4,7 @@ defmodule NullaWeb.UserController do
alias Nulla.Models.Note
alias Nulla.Models.InstanceSettings
alias Nulla.ActivityPub
alias Nulla.Utils
def show(conn, %{"username" => username}) do
accept = List.first(get_req_header(conn, "accept"))
@ -17,7 +18,19 @@ defmodule NullaWeb.UserController do
|> put_resp_content_type("application/activity+json")
|> json(ActivityPub.user(domain, user))
else
render(conn, :show, domain: domain, user: user, notes: notes, layout: false)
following = Utils.count_following_by_username!(user.username)
followers = Utils.count_followers_by_username!(user.username)
render(
conn,
:show,
domain: domain,
user: user,
notes: notes,
following: following,
followers: followers,
layout: false
)
end
end
end