Przeglądaj źródła

Update AP Helpers

Daniel Supernault 5 lat temu
rodzic
commit
b08b36127c
1 zmienionych plików z 16 dodań i 1 usunięć
  1. 16 1
      app/Util/ActivityPub/Helpers.php

+ 16 - 1
app/Util/ActivityPub/Helpers.php

@@ -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;
+	}
 }