From e6e16d2cdd220fe803d89f86b741af3ff3c1feaa Mon Sep 17 00:00:00 2001
From: a
Date: Fri, 23 Dec 2022 08:02:33 -0600
Subject: [PATCH 1/3] Fix: Use correct response type and remove Accept from
http signature
---
app/Http/Controllers/FederationController.php | 2 +-
app/Http/Controllers/InstanceActorController.php | 4 ++--
app/Http/Controllers/ProfileController.php | 2 +-
app/Http/Controllers/StatusController.php | 2 +-
app/Util/ActivityPub/HttpSignature.php | 1 -
5 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/app/Http/Controllers/FederationController.php b/app/Http/Controllers/FederationController.php
index f498c7317..42988ec99 100644
--- a/app/Http/Controllers/FederationController.php
+++ b/app/Http/Controllers/FederationController.php
@@ -131,7 +131,7 @@ class FederationController extends Controller
'orderedItems' => []
];
- return response(json_encode($res, JSON_UNESCAPED_SLASHES))->header('Content-Type', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"');
+ return response(json_encode($res, JSON_UNESCAPED_SLASHES))->header('Content-Type', 'application/activity+json');
}
public function userInbox(Request $request, $username)
diff --git a/app/Http/Controllers/InstanceActorController.php b/app/Http/Controllers/InstanceActorController.php
index 932155420..0eb796732 100644
--- a/app/Http/Controllers/InstanceActorController.php
+++ b/app/Http/Controllers/InstanceActorController.php
@@ -14,7 +14,7 @@ class InstanceActorController extends Controller
$res = (new InstanceActor())->first()->getActor();
return json_encode($res, JSON_UNESCAPED_SLASHES);
});
- return response($res)->header('Content-Type', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"');
+ return response($res)->header('Content-Type', 'application/activity+json');
}
public function inbox()
@@ -32,6 +32,6 @@ class InstanceActorController extends Controller
'first' => config('app.url') . '/i/actor/outbox?page=true',
'last' => config('app.url') . '/i/actor/outbox?min_id=0page=true'
], JSON_UNESCAPED_SLASHES);
- return response($res)->header('Content-Type', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"');
+ return response($res)->header('Content-Type', 'application/activity+json');
}
}
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index 0810956b9..3f6795d5b 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -191,7 +191,7 @@ class ProfileController extends Controller
$fractal = new Fractal\Manager();
$resource = new Fractal\Resource\Item($user, new ProfileTransformer);
$res = $fractal->createData($resource)->toArray();
- return response(json_encode($res['data']))->header('Content-Type', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"');
+ return response(json_encode($res['data']))->header('Content-Type', 'application/activity+json');
});
}
diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php
index 040f2fdb1..117124bb9 100644
--- a/app/Http/Controllers/StatusController.php
+++ b/app/Http/Controllers/StatusController.php
@@ -293,7 +293,7 @@ class StatusController extends Controller
$resource = new Fractal\Resource\Item($status, $object);
$res = $fractal->createData($resource)->toArray();
- return response()->json($res['data'], 200, ['Content-Type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
+ return response()->json($res['data'], 200, ['Content-Type' => 'application/activity+json'], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
}
public function edit(Request $request, $username, $id)
diff --git a/app/Util/ActivityPub/HttpSignature.php b/app/Util/ActivityPub/HttpSignature.php
index 5204a5f4b..8c8dad99f 100644
--- a/app/Util/ActivityPub/HttpSignature.php
+++ b/app/Util/ActivityPub/HttpSignature.php
@@ -132,7 +132,6 @@ class HttpSignature {
'(request-target)' => 'post '.parse_url($url, PHP_URL_PATH),
'Date' => $date->format('D, d M Y H:i:s \G\M\T'),
'Host' => parse_url($url, PHP_URL_HOST),
- 'Accept' => 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
];
if($digest) {
From 9bf651e442dcf050514192a54c696a01affb28da Mon Sep 17 00:00:00 2001
From: a
Date: Fri, 23 Dec 2022 08:12:59 -0600
Subject: [PATCH 2/3] remove unneeded duplicate accept type
---
app/Services/ActivityPubFetchService.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/Services/ActivityPubFetchService.php b/app/Services/ActivityPubFetchService.php
index 49e1e7cf5..5c0d48c7f 100644
--- a/app/Services/ActivityPubFetchService.php
+++ b/app/Services/ActivityPubFetchService.php
@@ -17,7 +17,7 @@ class ActivityPubFetchService
}
$headers = HttpSignature::instanceActorSign($url, false);
- $headers['Accept'] = 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"';
+ $headers['Accept'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"';
$headers['User-Agent'] = '(Pixelfed/'.config('pixelfed.version').'; +'.config('app.url').')';
try {
From 9471fa0078fe144ad359d1da4e63146f11a5caf5 Mon Sep 17 00:00:00 2001
From: a
Date: Fri, 23 Dec 2022 08:21:03 -0600
Subject: [PATCH 3/3] more semantically correct webfinger (use rel=self, allow
type=ld+json)
---
app/Services/WebfingerService.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/Services/WebfingerService.php b/app/Services/WebfingerService.php
index 807914664..78a0008bd 100644
--- a/app/Services/WebfingerService.php
+++ b/app/Services/WebfingerService.php
@@ -48,9 +48,11 @@ class WebfingerService
$link = collect($webfinger['links'])
->filter(function($link) {
return $link &&
+ isset($link['rel']) &&
isset($link['type']) &&
isset($link['href']) &&
- $link['type'] == 'application/activity+json';
+ $link['rel'] == 'self' &&
+ $link['type'] == 'application/activity+json' || $link['type'] == 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"';
})
->pluck('href')
->first();