1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-22 15:55:14 +00:00

Update AP Helpers

This commit is contained in:
Daniel Supernault 2019-12-31 22:00:55 -07:00
parent 01dd5db7f5
commit b08b36127c
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -406,7 +406,6 @@ class Helpers {
$remoteUsername = "@{$username}@{$domain}";
abort_if(!self::validateUrl($res['inbox']), 400);
abort_if(!self::validateUrl($res['outbox']), 400);
abort_if(!self::validateUrl($res['id']), 400);
$profile = Profile::whereRemoteUrl($res['id'])->first();
@ -451,4 +450,20 @@ class Helpers {
$response = curl_exec($ch);
return;
}
public static function apSignedPostRequest($senderProfile, $url, $body)
{
abort_if(!self::validateUrl($url), 400);
$payload = json_encode($body);
$headers = HttpSignature::sign($senderProfile, $url, $body);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HEADER, true);
$response = curl_exec($ch);
return;
}
}