This commit is contained in:
Mirai Kumiko 2025-06-17 12:06:36 +02:00
parent 58049c93d4
commit 894866ca03
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
22 changed files with 344 additions and 213 deletions

View file

@ -1,7 +1,7 @@
defmodule NullaWeb.OutboxController do
use NullaWeb, :controller
alias Nulla.ActivityPub
alias Nulla.Models.User
alias Nulla.Models.Actor
alias Nulla.Models.Note
alias Nulla.Models.InstanceSettings
@ -10,17 +10,17 @@ defmodule NullaWeb.OutboxController do
"true" ->
instance_settings = InstanceSettings.get_instance_settings!()
domain = instance_settings.domain
user = User.get_user_by_username!(username)
actor = Actor.get_actor(username, domain)
max_id = params["max_id"] && String.to_integer(params["max_id"])
notes =
if max_id do
Note.get_before_notes(user.id, max_id)
Note.get_before_notes(actor.id, max_id)
else
Note.get_latest_notes(user.id)
Note.get_latest_notes(actor.id)
end
items = Enum.map(notes, &ActivityPub.render_activity(&1, domain))
items = Enum.map(notes, &ActivityPub.activity_note(&1))
next_max_id =
case List.last(notes) do
@ -44,8 +44,8 @@ defmodule NullaWeb.OutboxController do
_ ->
instance_settings = InstanceSettings.get_instance_settings!()
domain = instance_settings.domain
user = User.get_user_by_username!(username)
total = Note.get_total_notes_count(user.id)
actor = Actor.get_actor(username, domain)
total = Note.get_total_notes_count(actor.id)
conn
|> put_resp_content_type("application/activity+json")