[PLUGIN][WebHooks] Make request method configurable

This way, PUT can be used, which doesn't seem to be the standard, so isn't the default, but which makes sense to me, as it doesn't have a response, which we don't care about anyway
This commit is contained in:
Hugo Sales 2022-03-24 00:50:27 +00:00
parent 48b42c539c
commit 7027633ed5
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 5 additions and 1 deletions

View File

@ -89,7 +89,8 @@ class WebHooks extends Plugin
$json = str_replace('"activity":"%activity%"', '"activity":' . \Plugin\ActivityPub\Util\Model\Activity::toJson($activity), json_encode($data));
Log::debug("WebHooks: POST {$target} on behalf of actor {$actor->getId()} ({$actor->getNickname()})", [$data, ['json' => $json]]);
try {
HTTPClient::post($target, ['body' => $json, 'headers' => ['content-type' => 'application/json', 'user-agent' => 'GNU social']]);
$method = Common::config('plugin_webhooks', 'method');
HTTPClient::{$method}($target, ['body' => $json, 'headers' => ['content-type' => 'application/json', 'user-agent' => 'GNU social']]);
} catch (Exception $e) {
Log::debug("WebHooks: Failed POST {$target} on behalf of actor {$actor->getId()} ({$actor->getNickname()})", [$e]);
}

View File

@ -135,6 +135,9 @@ parameters:
max_px: 64000
max_file_size: 4000000
plugin_webhooks:
method: post
theme:
server:
ssl: