summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-12-10 10:00:17 +0100
committerGravatar default2023-12-10 10:00:17 +0100
commit95ccff541c77052a4ff49421b8ad9d320075ffd4 (patch)
tree90f4165355b16078da3241e34e244849bd864948
parentCall is_msg_for_me() from global queue input messages. (diff)
downloadsnac2-95ccff541c77052a4ff49421b8ad9d320075ffd4.tar.gz
snac2-95ccff541c77052a4ff49421b8ad9d320075ffd4.tar.xz
snac2-95ccff541c77052a4ff49421b8ad9d320075ffd4.zip
process_input_message() returns -1 on errors.
-rw-r--r--activitypub.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/activitypub.c b/activitypub.c
index 62b4faf..517b942 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -1468,13 +1468,17 @@ int update_question(snac *user, const char *id)
1468int process_input_message(snac *snac, xs_dict *msg, xs_dict *req) 1468int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
1469/* processes an ActivityPub message from the input queue */ 1469/* processes an ActivityPub message from the input queue */
1470{ 1470{
1471 /* actor and type exist, were checked previously */
1472 char *actor = xs_dict_get(msg, "actor"); 1471 char *actor = xs_dict_get(msg, "actor");
1473 char *type = xs_dict_get(msg, "type"); 1472 char *type = xs_dict_get(msg, "type");
1474 xs *actor_o = NULL; 1473 xs *actor_o = NULL;
1475 int a_status; 1474 int a_status;
1476 int do_notify = 0; 1475 int do_notify = 0;
1477 1476
1477 if (xs_is_null(actor) || *actor == '\0') {
1478 snac_debug(snac, 0, xs_fmt("malformed message (bad actor)"));
1479 return -1;
1480 }
1481
1478 /* question votes may not have a type */ 1482 /* question votes may not have a type */
1479 if (xs_is_null(type)) 1483 if (xs_is_null(type))
1480 type = "Note"; 1484 type = "Note";
@@ -1482,12 +1486,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
1482 /* reject uninteresting messages right now */ 1486 /* reject uninteresting messages right now */
1483 if (strcmp(type, "Add") == 0) { 1487 if (strcmp(type, "Add") == 0) {
1484 snac_debug(snac, 0, xs_fmt("Ignored message of type '%s'", type)); 1488 snac_debug(snac, 0, xs_fmt("Ignored message of type '%s'", type));
1485 return 1; 1489 return -1;
1486 }
1487
1488 if (xs_is_null(actor)) {
1489 snac_debug(snac, 0, xs_fmt("malformed message"));
1490 return 1;
1491 } 1490 }
1492 1491
1493 char *object, *utype; 1492 char *object, *utype;
@@ -1523,7 +1522,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
1523 snac_debug(snac, 1, 1522 snac_debug(snac, 1,
1524 xs_fmt("dropping message due to actor error %s %d", actor, a_status)); 1523 xs_fmt("dropping message due to actor error %s %d", actor, a_status));
1525 1524
1526 return 1; 1525 return -1;
1527 } 1526 }
1528 1527
1529 if (!valid_status(a_status)) { 1528 if (!valid_status(a_status)) {
@@ -1542,7 +1541,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
1542 1541
1543 srv_archive_error("check_signature", sig_err, req, msg); 1542 srv_archive_error("check_signature", sig_err, req, msg);
1544 1543
1545 return 1; 1544 return -1;
1546 } 1545 }
1547 1546
1548 if (strcmp(type, "Follow") == 0) { /** **/ 1547 if (strcmp(type, "Follow") == 0) { /** **/