summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-08-13 16:09:20 +0200
committerGravatar default2023-08-13 16:09:20 +0200
commitc8d535a154a8bf6a7bc97a921afeb3dbbf51c204 (patch)
tree8877c4462e4fb6fc1fc6bba92c37be248bd8526e
parentDon't archive Accept + Create activities as errors. (diff)
downloadsnac2-c8d535a154a8bf6a7bc97a921afeb3dbbf51c204.tar.gz
snac2-c8d535a154a8bf6a7bc97a921afeb3dbbf51c204.tar.xz
snac2-c8d535a154a8bf6a7bc97a921afeb3dbbf51c204.zip
Ignore 'Add' activities ASAP.
-rw-r--r--activitypub.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/activitypub.c b/activitypub.c
index e0d923d..a834fad 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -1412,6 +1412,12 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
1412 if (xs_is_null(type)) 1412 if (xs_is_null(type))
1413 type = "Note"; 1413 type = "Note";
1414 1414
1415 /* reject uninteresting messages right now */
1416 if (strcmp(type, "Add") == 0) {
1417 snac_debug(snac, 0, xs_fmt("Ignored message of type '%s'", type));
1418 return 1;
1419 }
1420
1415 if (xs_is_null(actor)) { 1421 if (xs_is_null(actor)) {
1416 snac_debug(snac, 0, xs_fmt("malformed message")); 1422 snac_debug(snac, 0, xs_fmt("malformed message"));
1417 return 1; 1423 return 1;
@@ -2084,9 +2090,9 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path,
2084 2090
2085 /* decode the message */ 2091 /* decode the message */
2086 xs *msg = xs_json_loads(payload); 2092 xs *msg = xs_json_loads(payload);
2087 const char *id; 2093 const char *id = xs_dict_get(msg, "id");
2088 2094
2089 if (msg == NULL || xs_is_null(id = xs_dict_get(msg, "id"))) { 2095 if (msg == NULL) {
2090 srv_log(xs_fmt("activitypub_post_handler JSON error %s", q_path)); 2096 srv_log(xs_fmt("activitypub_post_handler JSON error %s", q_path));
2091 2097
2092 srv_archive_error("activitypub_post_handler", "JSON error", req, payload); 2098 srv_archive_error("activitypub_post_handler", "JSON error", req, payload);
@@ -2096,7 +2102,7 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path,
2096 return 400; 2102 return 400;
2097 } 2103 }
2098 2104
2099 if (is_instance_blocked(id)) { 2105 if (id && is_instance_blocked(id)) {
2100 srv_debug(1, xs_fmt("full instance block for %s", id)); 2106 srv_debug(1, xs_fmt("full instance block for %s", id));
2101 2107
2102 *body = xs_str_new("blocked"); 2108 *body = xs_str_new("blocked");
@@ -2106,7 +2112,6 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path,
2106 2112
2107 /* get the user and path */ 2113 /* get the user and path */
2108 xs *l = xs_split_n(q_path, "/", 2); 2114 xs *l = xs_split_n(q_path, "/", 2);
2109 char *uid;
2110 2115
2111 if (xs_list_len(l) != 3 || strcmp(xs_list_get(l, 2), "inbox") != 0) { 2116 if (xs_list_len(l) != 3 || strcmp(xs_list_get(l, 2), "inbox") != 0) {
2112 /* strange q_path */ 2117 /* strange q_path */
@@ -2114,7 +2119,7 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path,
2114 return 404; 2119 return 404;
2115 } 2120 }
2116 2121
2117 uid = xs_list_get(l, 1); 2122 const char *uid = xs_list_get(l, 1);
2118 if (!user_open(&snac, uid)) { 2123 if (!user_open(&snac, uid)) {
2119 /* invalid user */ 2124 /* invalid user */
2120 srv_debug(1, xs_fmt("activitypub_post_handler bad user %s", uid)); 2125 srv_debug(1, xs_fmt("activitypub_post_handler bad user %s", uid));