From cc3fe2f2cf53757bfc62e09d329cf7e86b311c54 Mon Sep 17 00:00:00 2001 From: notfire Date: Mon, 10 Mar 2025 10:23:20 -0400 Subject: [PATCH] e --- admin/fedi.php | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/admin/fedi.php b/admin/fedi.php index 513cc08..58847cd 100644 --- a/admin/fedi.php +++ b/admin/fedi.php @@ -17,7 +17,7 @@ $contentO = $arr["text"]; $contentR = $arr["responsetext"]; $url = "{$pageProto}://" . $_SERVER["HTTP_HOST"] . $pagePath . "/fetch.php?id={$id}"; -if ($arr["isrespondedto"] == "f") { +if (strlen($arr["fedipostid"]) == 0) { curl_setopt($ch, CURLOPT_URL, $fediAPIRoute); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); @@ -31,29 +31,25 @@ if ($arr["isrespondedto"] == "f") { } $resp = curl_exec($ch); - fwrite(STDERR, curl_error()); - fwrite(STDERR, curl_getinfo()); $jsonResp = json_decode($resp, true); $fediID = $jsonResp["id"]; pg_update($db, "data", array("fedipostid" => $fediID), array("id" => $id)); } else { - if (strlen($arr["fedipostid"]) > 0) { - curl_setopt($ch, CURLOPT_URL, ($fediAPIRoute . "/" . $arr["fedipostid"])); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); + curl_setopt($ch, CURLOPT_URL, ($fediAPIRoute . "/" . $arr["fedipostid"])); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); - if ($arr["iscwed"] == "t") { - $contentCW = $arr["cw"]; - curl_setopt($ch, CURLOPT_POSTFIELDS, - http_build_query(array('status' => "question: {$contentO}\n\nresponse: {$contentR}\n\nlink: {$url}", 'visibility' => "{$fediVisibility}", 'spoiler_text' => "anonymous question response (automated); cw: {$contentCW}"))); - } else { - curl_setopt($ch, CURLOPT_POSTFIELDS, - http_build_query(array('status' => "question: {$contentO}\n\nresponse: {$contentR}\n\nlink: {$url}", 'visibility' => "{$fediVisibility}", 'spoiler_text' => "anonymous question response (automated)"))); - } - - curl_exec($ch); + if ($arr["iscwed"] == "t") { + $contentCW = $arr["cw"]; + curl_setopt($ch, CURLOPT_POSTFIELDS, + http_build_query(array('status' => "question: {$contentO}\n\nresponse: {$contentR}\n\nlink: {$url}", 'visibility' => "{$fediVisibility}", 'spoiler_text' => "anonymous question response (automated); cw: {$contentCW}"))); + } else { + curl_setopt($ch, CURLOPT_POSTFIELDS, + http_build_query(array('status' => "question: {$contentO}\n\nresponse: {$contentR}\n\nlink: {$url}", 'visibility' => "{$fediVisibility}", 'spoiler_text' => "anonymous question response (automated)"))); } + + curl_exec($ch); } curl_close($ch);