mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 00:03:16 +00:00
Update FederationController, add inbox logic
This commit is contained in:
parent
75c7fcd182
commit
0144a5fdf6
1 changed files with 23 additions and 0 deletions
|
@ -170,6 +170,29 @@ XML;
|
|||
|
||||
public function userInbox(Request $request, $username)
|
||||
{
|
||||
if (config('pixelfed.activitypub_enabled') == false) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$profile = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
|
||||
$body = $request->getContent();
|
||||
$bodyDecoded = json_decode($body, true);
|
||||
$signature = $request->header('signature');
|
||||
if(!$signature) {
|
||||
abort(400, 'Missing signature header');
|
||||
}
|
||||
$signatureData = HttpSignature::parseSignatureHeader($signature);
|
||||
$actor = Profile::whereKeyId($signatureData['keyId'])->first();
|
||||
if(!$actor) {
|
||||
$actor = Helpers::profileFirstOrNew($bodyDecoded['actor']);
|
||||
}
|
||||
$pkey = openssl_pkey_get_public($actor->public_key);
|
||||
$inboxPath = "/users/{$profile->username}/inbox";
|
||||
list($verified, $headers) = HTTPSignature::verify($pkey, $signatureData, $request->headers->all(), $inboxPath, $body);
|
||||
if($verified !== 1) {
|
||||
abort(400, 'Invalid signature.');
|
||||
}
|
||||
InboxWorker::dispatch($request->headers->all(), $profile, $bodyDecoded);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue