mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update AP Helpers
This commit is contained in:
parent
764ab76e90
commit
823bcbc69a
1 changed files with 13 additions and 25 deletions
|
@ -23,6 +23,7 @@ use App\Jobs\ImageOptimizePipeline\{ImageOptimize,ImageThumbnail};
|
|||
use App\Jobs\StatusPipeline\NewStatusPipeline;
|
||||
use App\Util\ActivityPub\HttpSignature;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Services\ActivityPubDeliveryService;
|
||||
|
||||
class Helpers {
|
||||
|
||||
|
@ -435,35 +436,22 @@ class Helpers {
|
|||
return self::profileFirstOrNew($url);
|
||||
}
|
||||
|
||||
public static function sendSignedObject($senderProfile, $url, $body)
|
||||
public static function sendSignedObject($profile, $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;
|
||||
ActivityPubDeliveryService::queue()
|
||||
->from($profile)
|
||||
->to($url)
|
||||
->payload($body)
|
||||
->send();
|
||||
}
|
||||
|
||||
public static function apSignedPostRequest($senderProfile, $url, $body)
|
||||
public static function apSignedPostRequest($profile, $url, $body)
|
||||
{
|
||||
abort_if(!self::validateUrl($url), 400);
|
||||
ActivityPubDeliveryService::queue()
|
||||
->from($profile)
|
||||
->to($url)
|
||||
->payload($body)
|
||||
->send();
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue