commit a114d50

default  ·  2023-06-29 06:26:44 +0000 UTC
parent 057827e
Call is_instance_blocked() from activitypub_post_handler().
1 files changed,  +11, -2
+11, -2
 1@@ -1994,13 +1994,22 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path,
 2 
 3     /* decode the message */
 4     xs *msg = xs_json_loads(payload);
 5+    const char *id;
 6 
 7-    if (msg == NULL) {
 8+    if (msg == NULL || xs_is_null(id = xs_dict_get(msg, "id"))) {
 9         srv_log(xs_fmt("activitypub_post_handler JSON error %s", q_path));
10 
11         *body  = xs_str_new("JSON error");
12         *ctype = "text/plain";
13-        status = 400;
14+        return 400;
15+    }
16+
17+    if (is_instance_blocked(id)) {
18+        srv_debug(1, xs_fmt("full instance block for %s", id));
19+
20+        *body  = xs_str_new("blocked");
21+        *ctype = "text/plain";
22+        return 403;
23     }
24 
25     /* get the user and path */