From 0bd52b7bee29fc106a3a647bfaf0e901d75a9fa6 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 7 Nov 2018 17:09:08 +0100 Subject: [PATCH] Handle mastodon's headers correctly Signed-off-by: Thomas Citharel --- .../controllers/activity_pub_controller.ex | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/mobilizon_web/controllers/activity_pub_controller.ex b/lib/mobilizon_web/controllers/activity_pub_controller.ex index 68ad77068..7d377df63 100644 --- a/lib/mobilizon_web/controllers/activity_pub_controller.ex +++ b/lib/mobilizon_web/controllers/activity_pub_controller.ex @@ -13,9 +13,10 @@ defmodule MobilizonWeb.ActivityPubController do with %Actor{} = actor <- Actors.get_local_actor_by_name(name) do case get_req_header(conn, "accept") do ["application/activity+json"] -> - conn - |> put_resp_header("content-type", "application/activity+json") - |> json(ActorView.render("actor.json", %{actor: actor})) + conn |> render_ap_actor(actor) + + ["application/activity+json, application/ld+json"] -> + conn |> render_ap_actor(actor) _ -> conn @@ -27,6 +28,12 @@ defmodule MobilizonWeb.ActivityPubController do 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 with %Event{} = event <- Events.get_event_full_by_uuid(uuid), true <- event.public do