From 0bd609f5be9aa24bced629273ff2428058388ac3 Mon Sep 17 00:00:00 2001 From: default Date: Wed, 3 May 2023 07:57:10 +0200 Subject: Fixed missing notifications in certain circunstancies. --- html.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'html.c') diff --git a/html.c b/html.c index 5f57262..9d6fbc6 100644 --- a/html.c +++ b/html.c @@ -1226,7 +1226,7 @@ xs_str *html_notifications(snac *snac) const char *actor_id = xs_dict_get(noti, "actor"); xs *actor = NULL; - if (!valid_status(object_get(actor_id, &actor))) + if (!valid_status(actor_get(snac, actor_id, &actor))) continue; xs *a_name = actor_name(actor); -- cgit v1.2.3 From 511f5062b7df26c47409c88649f24d68bbd43ccb Mon Sep 17 00:00:00 2001 From: default Date: Thu, 4 May 2023 09:19:26 +0200 Subject: Deleted real unused parameters. --- activitypub.c | 4 ++-- data.c | 2 +- html.c | 15 +++++++-------- snac.h | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) (limited to 'html.c') diff --git a/activitypub.c b/activitypub.c index b20ae0f..13b1ce2 100644 --- a/activitypub.c +++ b/activitypub.c @@ -109,7 +109,7 @@ int actor_request(snac *snac, const char *actor, xs_dict **data) if (valid_status(status2)) { /* renew data */ - status = actor_add(snac, actor, payload); + status = actor_add(actor, payload); if (data != NULL) { *data = payload; @@ -1121,7 +1121,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req) else if (strcmp(type, "Update") == 0) { if (strcmp(utype, "Person") == 0) { - actor_add(snac, actor, xs_dict_get(msg, "object")); + actor_add(actor, xs_dict_get(msg, "object")); snac_log(snac, xs_fmt("updated actor %s", actor)); } diff --git a/data.c b/data.c index edeb676..f03fd71 100644 --- a/data.c +++ b/data.c @@ -1349,7 +1349,7 @@ int is_hidden(snac *snac, const char *id) } -int actor_add(snac *snac, const char *actor, xs_dict *msg) +int actor_add(const char *actor, xs_dict *msg) /* adds an actor */ { return object_add_ow(actor, msg); diff --git a/html.c b/html.c index 9d6fbc6..2aa6514 100644 --- a/html.c +++ b/html.c @@ -79,7 +79,7 @@ xs_str *actor_name(xs_dict *actor) } -d_char *html_actor_icon(snac *snac, d_char *os, char *actor, +xs_str *html_actor_icon(xs_str *os, char *actor, const char *date, const char *udate, const char *url, int priv) { xs *s = xs_str_new(NULL); @@ -168,7 +168,7 @@ d_char *html_msg_icon(snac *snac, d_char *os, char *msg) date = xs_dict_get(msg, "published"); udate = xs_dict_get(msg, "updated"); - os = html_actor_icon(snac, os, actor, date, udate, url, priv); + os = html_actor_icon(os, actor, date, udate, url, priv); } return os; @@ -983,7 +983,7 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, } -d_char *html_user_footer(snac *snac, d_char *s) +xs_str *html_user_footer(xs_str *s) { xs *s1 = xs_fmt( "
\n" @@ -1064,7 +1064,7 @@ d_char *html_timeline(snac *snac, char *list, int local, int skip, int show, int s = xs_str_cat(s, s1); } - s = html_user_footer(snac, s); + s = html_user_footer(s); s = xs_str_cat(s, "\n\n"); @@ -1088,8 +1088,7 @@ d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *heade if (valid_status(actor_get(snac, actor_id, &actor))) { s = xs_str_cat(s, "
\n"); - s = html_actor_icon(snac, s, actor, xs_dict_get(actor, "published"), NULL, NULL, 0); - + s = html_actor_icon(s, actor, xs_dict_get(actor, "published"), NULL, NULL, 0); /* content (user bio) */ char *c = xs_dict_get(actor, "summary"); @@ -1182,7 +1181,7 @@ d_char *html_people(snac *snac) s = html_people_list(snac, s, wers, L("People that follows you"), "e"); - s = html_user_footer(snac, s); + s = html_user_footer(s); s = xs_str_cat(s, "\n\n"); @@ -1277,7 +1276,7 @@ xs_str *html_notifications(snac *snac) s = xs_str_cat(s, s1); } - s = html_user_footer(snac, s); + s = html_user_footer(s); s = xs_str_cat(s, "\n\n"); diff --git a/snac.h b/snac.h index a162618..54c8e51 100644 --- a/snac.h +++ b/snac.h @@ -128,7 +128,7 @@ int is_muted(snac *snac, const char *actor); void hide(snac *snac, const char *id); int is_hidden(snac *snac, const char *id); -int actor_add(snac *snac, const char *actor, xs_dict *msg); +int actor_add(const char *actor, xs_dict *msg); int actor_get(snac *snac, const char *actor, xs_dict **data); int static_get(snac *snac, const char *id, d_char **data, int *size); -- cgit v1.2.3 From 753eadfd1775545c5bfb4110ad2ba7cb61df9588 Mon Sep 17 00:00:00 2001 From: default Date: Thu, 4 May 2023 09:25:09 +0200 Subject: Added some const here and there. --- activitypub.c | 6 +++--- data.c | 2 +- html.c | 6 ++++-- httpd.c | 2 +- snac.h | 14 ++++++++------ 5 files changed, 17 insertions(+), 13 deletions(-) (limited to 'html.c') diff --git a/activitypub.c b/activitypub.c index 13b1ce2..86d33df 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1426,7 +1426,7 @@ int process_queue(void) /** HTTP handlers */ -int activitypub_get_handler(d_char *req, char *q_path, +int activitypub_get_handler(const xs_dict *req, const char *q_path, char **body, int *b_size, char **ctype) { int status = 200; @@ -1519,8 +1519,8 @@ int activitypub_get_handler(d_char *req, char *q_path, } -int activitypub_post_handler(d_char *req, char *q_path, - d_char *payload, int p_size, +int activitypub_post_handler(const xs_dict *req, const char *q_path, + char *payload, int p_size, char **body, int *b_size, char **ctype) /* processes an input message */ { diff --git a/data.c b/data.c index f03fd71..72b63f8 100644 --- a/data.c +++ b/data.c @@ -1814,7 +1814,7 @@ static xs_dict *_new_qmsg(const char *type, const xs_val *msg, int retries) } -void enqueue_input(snac *snac, xs_dict *msg, xs_dict *req, int retries) +void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries) /* enqueues an input message */ { xs *qmsg = _new_qmsg("input", msg, retries); diff --git a/html.c b/html.c index 2aa6514..3ba7930 100644 --- a/html.c +++ b/html.c @@ -1289,7 +1289,8 @@ xs_str *html_notifications(snac *snac) } -int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char **ctype) +int html_get_handler(const xs_dict *req, const char *q_path, + char **body, int *b_size, char **ctype) { char *accept = xs_dict_get(req, "accept"); int status = 404; @@ -1546,7 +1547,8 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char * } -int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, +int html_post_handler(const xs_dict *req, const char *q_path, + char *payload, int p_size, char **body, int *b_size, char **ctype) { int status = 0; diff --git a/httpd.c b/httpd.c index 70083a1..5520457 100644 --- a/httpd.c +++ b/httpd.c @@ -43,7 +43,7 @@ d_char *nodeinfo_2_0(void) } -int server_get_handler(d_char *req, char *q_path, +int server_get_handler(xs_dict *req, char *q_path, char **body, int *b_size, char **ctype) /* basic server services */ { diff --git a/snac.h b/snac.h index 54c8e51..5279453 100644 --- a/snac.h +++ b/snac.h @@ -155,7 +155,7 @@ void inbox_add(const char *inbox); void inbox_add_by_actor(const xs_dict *actor); xs_list *inbox_list(void); -void enqueue_input(snac *snac, xs_dict *msg, xs_dict *req, int retries); +void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries); void enqueue_output_raw(const char *keyid, const char *seckey, xs_dict *msg, xs_str *inbox, int retries); void enqueue_output(snac *snac, xs_dict *msg, xs_str *inbox, int retries); @@ -187,7 +187,7 @@ int check_signature(snac *snac, xs_dict *req, xs_str **err); void httpd(void); int webfinger_request(const char *qs, char **actor, char **user); -int webfinger_get_handler(d_char *req, char *q_path, +int webfinger_get_handler(xs_dict *req, char *q_path, char **body, int *b_size, char **ctype); const char *default_avatar_base64(void); @@ -220,17 +220,19 @@ int process_user_queue(snac *snac); void process_queue_item(xs_dict *q_item); int process_queue(void); -int activitypub_get_handler(d_char *req, char *q_path, +int activitypub_get_handler(const xs_dict *req, const char *q_path, char **body, int *b_size, char **ctype); -int activitypub_post_handler(d_char *req, char *q_path, +int activitypub_post_handler(const xs_dict *req, const char *q_path, char *payload, int p_size, char **body, int *b_size, char **ctype); d_char *not_really_markdown(const char *content); d_char *sanitize(const char *str); -int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char **ctype); -int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, +int html_get_handler(const xs_dict *req, const char *q_path, + char **body, int *b_size, char **ctype); +int html_post_handler(const xs_dict *req, const char *q_path, + char *payload, int p_size, char **body, int *b_size, char **ctype); int snac_init(const char *_basedir); -- cgit v1.2.3 From 185aac23876f9ae5d9b613f8b9abd517c3ab3b4d Mon Sep 17 00:00:00 2001 From: default Date: Thu, 4 May 2023 09:28:36 +0200 Subject: Added -Wextra to C flags. --- Makefile | 2 +- activitypub.c | 2 ++ html.c | 3 +++ httpd.c | 6 ++++++ mastoapi.c | 13 +++++++++++++ webfinger.c | 2 ++ 6 files changed, 27 insertions(+), 1 deletion(-) (limited to 'html.c') diff --git a/Makefile b/Makefile index 710d61f..7dbd9e7 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PREFIX=/usr/local PREFIX_MAN=$(PREFIX)/man -CFLAGS?=-g -Wall +CFLAGS?=-g -Wall -Wextra all: snac diff --git a/activitypub.c b/activitypub.c index 86d33df..c25b733 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1524,6 +1524,8 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path, char **body, int *b_size, char **ctype) /* processes an input message */ { + (void)b_size; + int status = 202; /* accepted */ char *i_ctype = xs_dict_get(req, "content-type"); snac snac; diff --git a/html.c b/html.c index 3ba7930..3ebe70d 100644 --- a/html.c +++ b/html.c @@ -1551,6 +1551,9 @@ int html_post_handler(const xs_dict *req, const char *q_path, char *payload, int p_size, char **body, int *b_size, char **ctype) { + (void)p_size; + (void)ctype; + int status = 0; snac snac; char *uid, *p_path; diff --git a/httpd.c b/httpd.c index 5520457..fe93727 100644 --- a/httpd.c +++ b/httpd.c @@ -49,6 +49,8 @@ int server_get_handler(xs_dict *req, char *q_path, { int status = 0; + (void)req; + /* is it the server root? */ if (*q_path == '\0') { /* try to open greeting.html */ @@ -285,6 +287,8 @@ static jmp_buf on_break; void term_handler(int s) { + (void)s; + longjmp(on_break, 1); } @@ -401,6 +405,8 @@ static void *background_thread(void *arg) { time_t purge_time; + (void)arg; + /* first purge time */ purge_time = time(NULL) + 10 * 60; diff --git a/mastoapi.c b/mastoapi.c index c51c933..2413edb 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -175,6 +175,8 @@ const char *login_page = "" int oauth_get_handler(const xs_dict *req, const char *q_path, char **body, int *b_size, char **ctype) { + (void)b_size; + if (!xs_startswith(q_path, "/oauth/")) return 0; @@ -227,6 +229,9 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, const char *payload, int p_size, char **body, int *b_size, char **ctype) { + (void)p_size; + (void)b_size; + if (!xs_startswith(q_path, "/oauth/")) return 0; @@ -815,6 +820,8 @@ int process_auth_token(snac *snac, const xs_dict *req) int mastoapi_get_handler(const xs_dict *req, const char *q_path, char **body, int *b_size, char **ctype) { + (void)b_size; + if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) return 0; @@ -1474,6 +1481,9 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, const char *payload, int p_size, char **body, int *b_size, char **ctype) { + (void)p_size; + (void)b_size; + if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) return 0; @@ -1898,6 +1908,9 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path, const char *payload, int p_size, char **body, int *b_size, char **ctype) { + (void)p_size; + (void)b_size; + if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/")) return 0; diff --git a/webfinger.c b/webfinger.c index f56b6f2..765c469 100644 --- a/webfinger.c +++ b/webfinger.c @@ -104,6 +104,8 @@ int webfinger_get_handler(d_char *req, char *q_path, { int status; + (void)b_size; + if (strcmp(q_path, "/.well-known/webfinger") != 0) return 0; -- cgit v1.2.3 From 980a8d524fae11d17366e7aea56206d13f278e31 Mon Sep 17 00:00:00 2001 From: default Date: Thu, 4 May 2023 09:34:33 +0200 Subject: Fixed more warnings. --- activitypub.c | 3 ++- html.c | 1 + mastoapi.c | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'html.c') diff --git a/activitypub.c b/activitypub.c index c25b733..0d5439d 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1384,8 +1384,9 @@ void process_queue_item(xs_dict *q_item) xs *headers = xs_dict_new(); headers = xs_dict_append(headers, "content-type", "application/json"); - xs *rsp = xs_http_request("POST", url, headers, + xs *rsp = xs_http_request("POST", url, headers, body, strlen(body), &status, NULL, NULL, 0); + rsp = xs_free(rsp); srv_debug(0, xs_fmt("telegram post %d", status)); } diff --git a/html.c b/html.c index 3ebe70d..8d4203d 100644 --- a/html.c +++ b/html.c @@ -1282,6 +1282,7 @@ xs_str *html_notifications(snac *snac) /* set the check time to now */ xs *dummy = notify_check_time(snac, 1); + dummy = xs_free(dummy); timeline_touch(snac); diff --git a/mastoapi.c b/mastoapi.c index 2413edb..c333573 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -542,7 +542,6 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg) xs *f = xs_val_new(XSTYPE_FALSE); xs *t = xs_val_new(XSTYPE_TRUE); xs *n = xs_val_new(XSTYPE_NULL); - xs *el = xs_list_new(); xs *idx = NULL; xs *ixc = NULL; -- cgit v1.2.3