forked from AkkomaGang/akkoma
Use standard-compliant Accept header when fetching
Spec says clients MUST use this header and servers MUST respond to it, while servers merely SHOULD respond to the one we used before. https://www.w3.org/TR/activitypub/#retrieving-objects Fixes: AkkomaGang/akkoma#730
This commit is contained in:
parent
1135935cbe
commit
a4ce87a231
|
@ -324,7 +324,7 @@ defmodule Pleroma.Object.Fetcher do
|
|||
date = Pleroma.Signature.signed_date()
|
||||
|
||||
headers =
|
||||
[{"accept", "application/activity+json"}]
|
||||
[{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}]
|
||||
|> maybe_date_fetch(date)
|
||||
|> sign_fetch(id, date)
|
||||
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
defmodule HttpRequestMock do
|
||||
require Logger
|
||||
|
||||
def activitypub_object_headers, do: [{"content-type", "application/activity+json"}]
|
||||
def activitypub_object_headers,
|
||||
do: [
|
||||
{"content-type", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]
|
||||
|
||||
def request(
|
||||
%Tesla.Env{
|
||||
|
@ -97,7 +100,10 @@ defmodule HttpRequestMock do
|
|||
File.read!("test/fixtures/users_mock/masto_featured.json")
|
||||
|> String.replace("{{domain}}", "mastodon.sdf.org")
|
||||
|> String.replace("{{nickname}}", "rinpatch"),
|
||||
headers: [{"content-type", "application/activity+json"}]
|
||||
headers: [
|
||||
{"content-type",
|
||||
"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]
|
||||
}}
|
||||
end
|
||||
|
||||
|
@ -208,7 +214,7 @@ defmodule HttpRequestMock do
|
|||
"https://mst3k.interlinked.me/users/luciferMysticus",
|
||||
_,
|
||||
_,
|
||||
[{"accept", "application/activity+json"}]
|
||||
[{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}]
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
|
@ -231,7 +237,7 @@ defmodule HttpRequestMock do
|
|||
"https://hubzilla.example.org/channel/kaniini",
|
||||
_,
|
||||
_,
|
||||
[{"accept", "application/activity+json"}]
|
||||
[{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}]
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
|
@ -241,7 +247,9 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
def get("https://niu.moe/users/rye", _, _, [{"accept", "application/activity+json"}]) do
|
||||
def get("https://niu.moe/users/rye", _, _, [
|
||||
{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
|
@ -250,7 +258,9 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
def get("https://n1u.moe/users/rye", _, _, [{"accept", "application/activity+json"}]) do
|
||||
def get("https://n1u.moe/users/rye", _, _, [
|
||||
{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
|
@ -270,7 +280,9 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
def get("https://puckipedia.com/", _, _, [{"accept", "application/activity+json"}]) do
|
||||
def get("https://puckipedia.com/", _, _, [
|
||||
{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
|
@ -343,7 +355,7 @@ defmodule HttpRequestMock do
|
|||
end
|
||||
|
||||
def get("https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39", _, _, [
|
||||
{"accept", "application/activity+json"}
|
||||
{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
|
@ -353,7 +365,9 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
def get("https://mobilizon.org/@tcit", _, _, [{"accept", "application/activity+json"}]) do
|
||||
def get("https://mobilizon.org/@tcit", _, _, [
|
||||
{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
|
@ -417,7 +431,7 @@ defmodule HttpRequestMock do
|
|||
end
|
||||
|
||||
def get("http://mastodon.example.org/users/relay", _, _, [
|
||||
{"accept", "application/activity+json"}
|
||||
{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
|
@ -428,7 +442,7 @@ defmodule HttpRequestMock do
|
|||
end
|
||||
|
||||
def get("http://mastodon.example.org/users/gargron", _, _, [
|
||||
{"accept", "application/activity+json"}
|
||||
{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]) do
|
||||
{:error, :nxdomain}
|
||||
end
|
||||
|
@ -620,7 +634,9 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
def get("https://mstdn.io/users/mayuutann", _, _, [{"accept", "application/activity+json"}]) do
|
||||
def get("https://mstdn.io/users/mayuutann", _, _, [
|
||||
{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
|
@ -633,7 +649,7 @@ defmodule HttpRequestMock do
|
|||
"https://mstdn.io/users/mayuutann/statuses/99568293732299394",
|
||||
_,
|
||||
_,
|
||||
[{"accept", "application/activity+json"}]
|
||||
[{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}]
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
|
@ -779,7 +795,7 @@ defmodule HttpRequestMock do
|
|||
"http://gs.example.org:4040/index.php/user/1",
|
||||
_,
|
||||
_,
|
||||
[{"accept", "application/activity+json"}]
|
||||
[{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}]
|
||||
) do
|
||||
{:ok, %Tesla.Env{status: 406, body: ""}}
|
||||
end
|
||||
|
@ -966,7 +982,9 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
def get("https://social.heldscal.la/user/23211", _, _, [{"accept", "application/activity+json"}]) do
|
||||
def get("https://social.heldscal.la/user/23211", _, _, [
|
||||
{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]) do
|
||||
{:ok, Tesla.Mock.json(%{"id" => "https://social.heldscal.la/user/23211"}, status: 200)}
|
||||
end
|
||||
|
||||
|
@ -1207,12 +1225,15 @@ defmodule HttpRequestMock do
|
|||
File.read!("test/fixtures/users_mock/masto_featured.json")
|
||||
|> String.replace("{{domain}}", "lm.kazv.moe")
|
||||
|> String.replace("{{nickname}}", "mewmew"),
|
||||
headers: [{"content-type", "application/activity+json"}]
|
||||
headers: [
|
||||
{"content-type",
|
||||
"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://info.pleroma.site/activity.json", _, _, [
|
||||
{"accept", "application/activity+json"}
|
||||
{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
|
@ -1227,7 +1248,7 @@ defmodule HttpRequestMock do
|
|||
end
|
||||
|
||||
def get("https://info.pleroma.site/activity2.json", _, _, [
|
||||
{"accept", "application/activity+json"}
|
||||
{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
|
@ -1242,7 +1263,7 @@ defmodule HttpRequestMock do
|
|||
end
|
||||
|
||||
def get("https://info.pleroma.site/activity3.json", _, _, [
|
||||
{"accept", "application/activity+json"}
|
||||
{"accept", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
||||
]) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
|
|
Loading…
Reference in New Issue