This commit is contained in:
notfire 2025-03-10 10:23:20 -04:00
parent db756293aa
commit cc3fe2f2cf
Signed by: notfire
GPG key ID: 3AFDACAAB4E56B16

View file

@ -17,7 +17,7 @@ $contentO = $arr["text"];
$contentR = $arr["responsetext"]; $contentR = $arr["responsetext"];
$url = "{$pageProto}://" . $_SERVER["HTTP_HOST"] . $pagePath . "/fetch.php?id={$id}"; $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_URL, $fediAPIRoute);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@ -31,29 +31,25 @@ if ($arr["isrespondedto"] == "f") {
} }
$resp = curl_exec($ch); $resp = curl_exec($ch);
fwrite(STDERR, curl_error());
fwrite(STDERR, curl_getinfo());
$jsonResp = json_decode($resp, true); $jsonResp = json_decode($resp, true);
$fediID = $jsonResp["id"]; $fediID = $jsonResp["id"];
pg_update($db, "data", array("fedipostid" => $fediID), array("id" => $id)); pg_update($db, "data", array("fedipostid" => $fediID), array("id" => $id));
} else { } else {
if (strlen($arr["fedipostid"]) > 0) { curl_setopt($ch, CURLOPT_URL, ($fediAPIRoute . "/" . $arr["fedipostid"]));
curl_setopt($ch, CURLOPT_URL, ($fediAPIRoute . "/" . $arr["fedipostid"])); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
if ($arr["iscwed"] == "t") { if ($arr["iscwed"] == "t") {
$contentCW = $arr["cw"]; $contentCW = $arr["cw"];
curl_setopt($ch, CURLOPT_POSTFIELDS, 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}"))); http_build_query(array('status' => "question: {$contentO}\n\nresponse: {$contentR}\n\nlink: {$url}", 'visibility' => "{$fediVisibility}", 'spoiler_text' => "anonymous question response (automated); cw: {$contentCW}")));
} else { } else {
curl_setopt($ch, CURLOPT_POSTFIELDS, 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)"))); 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_exec($ch);
} }
curl_close($ch); curl_close($ch);