mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 22:41:27 +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\Jobs\StatusPipeline\NewStatusPipeline;
|
||||||
use App\Util\ActivityPub\HttpSignature;
|
use App\Util\ActivityPub\HttpSignature;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use App\Services\ActivityPubDeliveryService;
|
||||||
|
|
||||||
class Helpers {
|
class Helpers {
|
||||||
|
|
||||||
|
@ -435,35 +436,22 @@ class Helpers {
|
||||||
return self::profileFirstOrNew($url);
|
return self::profileFirstOrNew($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function sendSignedObject($senderProfile, $url, $body)
|
public static function sendSignedObject($profile, $url, $body)
|
||||||
{
|
{
|
||||||
abort_if(!self::validateUrl($url), 400);
|
ActivityPubDeliveryService::queue()
|
||||||
|
->from($profile)
|
||||||
$payload = json_encode($body);
|
->to($url)
|
||||||
$headers = HttpSignature::sign($senderProfile, $url, $body);
|
->payload($body)
|
||||||
|
->send();
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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