forked from potsda.mn/mobilizon
Set correct Content-Type on all AP endpoints
Closes #1210 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
2e9414767c
commit
aeaf22a224
|
@ -85,8 +85,9 @@ defmodule Mobilizon.Web.ActivityPubController do
|
|||
actor = Map.get(conn.assigns, :actor)
|
||||
|
||||
if actor_applicant_group_member?(group, actor) do
|
||||
json(
|
||||
conn,
|
||||
conn
|
||||
|> put_resp_content_type("application/activity+json")
|
||||
|> json(
|
||||
ActorView.render("member.json", %{
|
||||
member: member,
|
||||
actor_applicant: actor
|
||||
|
@ -168,7 +169,7 @@ defmodule Mobilizon.Web.ActivityPubController do
|
|||
def relay(conn, _params) do
|
||||
with {status, %Actor{} = actor} when status in [:commit, :ok] <- Cache.get_relay() do
|
||||
conn
|
||||
|> put_resp_header("content-type", "application/activity+json")
|
||||
|> put_resp_content_type("application/activity+json")
|
||||
|> json(ActorView.render("actor.json", %{actor: actor}))
|
||||
end
|
||||
end
|
||||
|
@ -194,7 +195,7 @@ defmodule Mobilizon.Web.ActivityPubController do
|
|||
page <- max(page, 1),
|
||||
%Actor{} = actor <- Actors.get_local_actor_by_name_with_preload(name) do
|
||||
conn
|
||||
|> put_resp_header("content-type", "application/activity+json")
|
||||
|> put_resp_content_type("application/activity+json")
|
||||
|> json(
|
||||
ActorView.render("#{collection}.json", %{
|
||||
actor: actor,
|
||||
|
@ -208,7 +209,7 @@ defmodule Mobilizon.Web.ActivityPubController do
|
|||
defp actor_collection(conn, collection, %{"name" => name}) do
|
||||
with %Actor{} = actor <- Actors.get_local_actor_by_name_with_preload(name) do
|
||||
conn
|
||||
|> put_resp_header("content-type", "application/activity+json")
|
||||
|> put_resp_content_type("application/activity+json")
|
||||
|> json(
|
||||
ActorView.render("#{collection}.json", %{
|
||||
actor: actor,
|
||||
|
|
|
@ -141,11 +141,13 @@ defmodule Mobilizon.Web.PageController do
|
|||
%Tombstone{} ->
|
||||
conn
|
||||
|> put_status(:gone)
|
||||
|> maybe_add_content_type_header()
|
||||
|> render(object_type, object: object)
|
||||
|
||||
_ ->
|
||||
conn
|
||||
|> maybe_add_noindex_header(object)
|
||||
|> maybe_add_content_type_header()
|
||||
|> render(object_type, object: object)
|
||||
end
|
||||
|
||||
|
@ -199,4 +201,14 @@ defmodule Mobilizon.Web.PageController do
|
|||
@spec is_person?(Actor.t()) :: boolean()
|
||||
defp is_person?(%Actor{type: :Person}), do: true
|
||||
defp is_person?(_), do: false
|
||||
|
||||
defp maybe_add_content_type_header(conn) do
|
||||
case get_format(conn) do
|
||||
"html" ->
|
||||
conn
|
||||
|
||||
"activity-json" ->
|
||||
put_resp_content_type(conn, "application/activity+json")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue