mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-23 06:51:27 +00:00
Merge pull request #681 from pixelfed/frontend-ui-refactor
Update FederationController, fixes #680
This commit is contained in:
commit
c837f5aea9
2 changed files with 11 additions and 3 deletions
|
@ -181,13 +181,20 @@ XML;
|
||||||
return ProfileController::accountCheck($profile);
|
return ProfileController::accountCheck($profile);
|
||||||
}
|
}
|
||||||
$body = $request->getContent();
|
$body = $request->getContent();
|
||||||
$bodyDecoded = json_decode($body, true);
|
$bodyDecoded = json_decode($body, true, 8);
|
||||||
$signature = $request->header('signature');
|
$signature = $request->header('signature');
|
||||||
if(!$signature) {
|
if(!$signature) {
|
||||||
abort(400, 'Missing signature header');
|
abort(400, 'Missing signature header');
|
||||||
}
|
}
|
||||||
$signatureData = HttpSignature::parseSignatureHeader($signature);
|
$signatureData = HttpSignature::parseSignatureHeader($signature);
|
||||||
$actor = Profile::whereKeyId($signatureData['keyId'])->first();
|
$keyId = Helpers::validateUrl($signatureData['keyId']);
|
||||||
|
$id = Helpers::validateUrl($bodyDecoded['id']);
|
||||||
|
$keyDomain = parse_url($keyId, PHP_URL_HOST);
|
||||||
|
$idDomain = parse_url($id, PHP_URL_HOST);
|
||||||
|
if(!$keyDomain || !$idDomain || $keyDomain !== $idDomain) {
|
||||||
|
abort(400, 'Invalid request');
|
||||||
|
}
|
||||||
|
$actor = Profile::whereKeyId($keyId)->first();
|
||||||
if(!$actor) {
|
if(!$actor) {
|
||||||
$actor = Helpers::profileFirstOrNew($bodyDecoded['actor']);
|
$actor = Helpers::profileFirstOrNew($bodyDecoded['actor']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,12 +167,13 @@ class Inbox
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = DB::transaction(function() use($activity, $actor) {
|
$status = DB::transaction(function() use($activity, $actor, $url) {
|
||||||
$caption = str_limit(strip_tags($activity['content']), config('pixelfed.max_caption_length'));
|
$caption = str_limit(strip_tags($activity['content']), config('pixelfed.max_caption_length'));
|
||||||
$status = new Status;
|
$status = new Status;
|
||||||
$status->profile_id = $actor->id;
|
$status->profile_id = $actor->id;
|
||||||
$status->caption = $caption;
|
$status->caption = $caption;
|
||||||
$status->visibility = $status->scope = 'public';
|
$status->visibility = $status->scope = 'public';
|
||||||
|
$status->uri = $url;
|
||||||
$status->url = $url;
|
$status->url = $url;
|
||||||
$status->save();
|
$status->save();
|
||||||
return $status;
|
return $status;
|
||||||
|
|
Loading…
Reference in a new issue