Fix activitypub.ex

This commit is contained in:
Mirai Kumiko 2025-06-19 07:39:11 +02:00
parent 1b4034dac6
commit d8e66d0dcb
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
3 changed files with 33 additions and 39 deletions

View file

@ -3,12 +3,9 @@ defmodule NullaWeb.NoteController do
alias Nulla.Repo
alias Nulla.ActivityPub
alias Nulla.Models.Note
alias Nulla.Models.InstanceSettings
def show(conn, %{"username" => username, "id" => id}) do
accept = List.first(get_req_header(conn, "accept"))
instance_settings = InstanceSettings.get_instance_settings!()
domain = instance_settings.domain
note = Note.get_note!(id) |> Repo.preload([:user, :media_attachments])
if username != note.user.username do
@ -21,9 +18,9 @@ defmodule NullaWeb.NoteController do
if accept in ["application/activity+json", "application/ld+json"] do
conn
|> put_resp_content_type("application/activity+json")
|> json(ActivityPub.note(domain, note))
|> json(ActivityPub.note(note))
else
render(conn, :show, domain: domain, note: note, layout: false)
render(conn, :show, note: note, layout: false)
end
end
end