merge-requests/5/head
Terence Eden 2024-02-16 09:34:09 +00:00
rodzic 51c71edf1e
commit 7269503af6
1 zmienionych plików z 5 dodań i 6 usunięć

Wyświetl plik

@ -73,8 +73,6 @@
// This runs the function of the path requested. // This runs the function of the path requested.
!empty( $_GET["path"] ) ? $path = $_GET["path"] : die(); !empty( $_GET["path"] ) ? $path = $_GET["path"] : die();
switch ($path) { switch ($path) {
case "":
die();
case ".well-known/webfinger": case ".well-known/webfinger":
webfinger(); webfinger();
case rawurldecode( $username ): case rawurldecode( $username ):
@ -256,7 +254,7 @@
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" ); curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($message) ); curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($message) );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers ); curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
$response = curl_exec( $ch ); curl_exec( $ch );
// Check for errors // Check for errors
if( curl_errno( $ch ) ) { if( curl_errno( $ch ) ) {
@ -392,6 +390,7 @@ HTML;
]; ];
// Construct the Message // Construct the Message
// The audience is public and it is sent to all followers
$message = [ $message = [
"@context" => "https://www.w3.org/ns/activitystreams", "@context" => "https://www.w3.org/ns/activitystreams",
"id" => "https://{$server}/posts/{$guid}.json", "id" => "https://{$server}/posts/{$guid}.json",
@ -427,6 +426,7 @@ HTML;
// Each server needs its own cURL handle // Each server needs its own cURL handle
// Each POST to an inbox needs to be signed separately // Each POST to an inbox needs to be signed separately
foreach ( $hosts as $host ) { foreach ( $hosts as $host ) {
// TODO: Not every host uses /inbox
$path = "/inbox"; $path = "/inbox";
// Get the signed headers // Get the signed headers
@ -437,7 +437,6 @@ HTML;
// POST the message and header to the requester's inbox // POST the message and header to the requester's inbox
$ch = curl_init( $remoteServerUrl ); $ch = curl_init( $remoteServerUrl );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" ); curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($message) ); curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($message) );