commit c83b601

default  ·  2023-03-31 17:09:59 +0000 UTC
parent 4070c00
In is_msg_public(), also look at 'Announce' messages.
1 files changed,  +13, -2
+13, -2
 1@@ -297,10 +297,16 @@ int is_msg_public(snac *snac, xs_dict *msg)
 2 int is_msg_for_me(snac *snac, xs_dict *c_msg)
 3 /* checks if this message is for me */
 4 {
 5-    char *type = xs_dict_get(c_msg, "type");
 6+    const char *type = xs_dict_get(c_msg, "type");
 7+
 8+    /* if it's an Announce by someone we don't follow, reject */
 9+    if (strcmp(type, "Announce") == 0) {
10+        if (!following_check(snac, xs_dict_get(c_msg, "actor")))
11+            return 0;
12+    }
13 
14     /* if it's not a Create, allow */
15-    if (xs_is_null(type) || strcmp(type, "Create") != 0)
16+    if (strcmp(type, "Create") != 0)
17         return 1;
18 
19     xs_dict *msg = xs_dict_get(c_msg, "object");
20@@ -938,6 +944,11 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
21     int a_status;
22     int do_notify = 0;
23 
24+    if (xs_is_null(actor) || xs_is_null(type)) {
25+        snac_debug(snac, 0, xs_fmt("malformed message"));
26+        return 1;
27+    }
28+
29     char *object, *utype;
30 
31     object = xs_dict_get(msg, "object");