snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit 349d6603e4cd4a8baff1db718afa83413b0dae5f
parent 3844bbf04f9b417ee9fc97f6f43db259a063a1da
Author: default <nobody@localhost>
Date:   Mon, 17 Feb 2025 08:13:39 +0100

Show the POST status also as string.

Diffstat:
Mactivitypub.c | 14+++++++++++---
Mxs_curl.h | 11+++++++++++
2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/activitypub.c b/activitypub.c @@ -2724,6 +2724,12 @@ int process_user_queue(snac *snac) } +xs_str *str_status(int status) +{ + return xs_fmt("%d %s", status, status < 0 ? xs_curl_strerr(status) : http_status_text(status)); +} + + void process_queue_item(xs_dict *q_item) /* processes an item from the global queue */ { @@ -2780,7 +2786,9 @@ void process_queue_item(xs_dict *q_item) else payload = xs_str_new(NULL); - srv_log(xs_fmt("output message: sent to inbox %s %d%s", inbox, status, payload)); + xs *s_status = str_status(status); + + srv_log(xs_fmt("output message: sent to inbox %s (%s)%s", inbox, s_status, payload)); if (!valid_status(status)) { retries++; @@ -2798,10 +2806,10 @@ void process_queue_item(xs_dict *q_item) || status == HTTP_STATUS_UNPROCESSABLE_CONTENT || status < 0) /* explicit error: discard */ - srv_log(xs_fmt("output message: error %s %d", inbox, status)); + srv_log(xs_fmt("output message: error %s (%s)", inbox, s_status)); else if (retries > queue_retry_max) - srv_log(xs_fmt("output message: giving up %s %d", inbox, status)); + srv_log(xs_fmt("output message: giving up %s (%s)", inbox, s_status)); else { /* requeue */ enqueue_output_raw(keyid, seckey, msg, inbox, retries, status); diff --git a/xs_curl.h b/xs_curl.h @@ -9,6 +9,8 @@ xs_dict *xs_http_request(const char *method, const char *url, const xs_str *body, int b_size, int *status, xs_str **payload, int *p_size, int timeout); +const char *xs_curl_strerr(int errnum); + #ifdef XS_IMPLEMENTATION #include <curl/curl.h> @@ -194,6 +196,15 @@ xs_dict *xs_http_request(const char *method, const char *url, return response; } + +const char *xs_curl_strerr(int errnum) +{ + CURLcode cc = errnum < 0 ? -errnum : errnum; + + return curl_easy_strerror(cc); +} + + #endif /* XS_IMPLEMENTATION */ #endif /* _XS_CURL_H */