Handle mastodon's headers correctly

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2018-11-07 17:09:08 +01:00
parent 5361371d8a
commit 3f0cb8a183

View file

@ -13,9 +13,10 @@ defmodule MobilizonWeb.ActivityPubController do
with %Actor{} = actor <- Actors.get_local_actor_by_name(name) do with %Actor{} = actor <- Actors.get_local_actor_by_name(name) do
case get_req_header(conn, "accept") do case get_req_header(conn, "accept") do
["application/activity+json"] -> ["application/activity+json"] ->
conn conn |> render_ap_actor(actor)
|> put_resp_header("content-type", "application/activity+json")
|> json(ActorView.render("actor.json", %{actor: actor})) ["application/activity+json, application/ld+json"] ->
conn |> render_ap_actor(actor)
_ -> _ ->
conn conn
@ -27,6 +28,12 @@ defmodule MobilizonWeb.ActivityPubController do
end end
end end
defp render_ap_actor(conn, %Actor{} = actor) do
conn
|> put_resp_header("content-type", "application/activity+json")
|> json(ActorView.render("actor.json", %{actor: actor}))
end
def event(conn, %{"uuid" => uuid}) do def event(conn, %{"uuid" => uuid}) do
with %Event{} = event <- Events.get_event_full_by_uuid(uuid), with %Event{} = event <- Events.get_event_full_by_uuid(uuid),
true <- event.public do true <- event.public do