From 823bcbc69ad5abb4762a91ccaceb82c012e3dd2b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 1 Feb 2020 11:42:24 -0700 Subject: [PATCH] Update AP Helpers --- app/Util/ActivityPub/Helpers.php | 38 +++++++++++--------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/app/Util/ActivityPub/Helpers.php b/app/Util/ActivityPub/Helpers.php index e6d85baec..527e960b1 100644 --- a/app/Util/ActivityPub/Helpers.php +++ b/app/Util/ActivityPub/Helpers.php @@ -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; } }