summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authorGravatar default2023-12-11 16:59:33 +0100
committerGravatar default2023-12-11 16:59:33 +0100
commitb1ecaba8035d0239051f01e4bdc7af5326a1d980 (patch)
treecb901a8265bc93021629856c969532ca1339c7fa /activitypub.c
parentFixed error message. (diff)
downloadsnac2-b1ecaba8035d0239051f01e4bdc7af5326a1d980.tar.gz
snac2-b1ecaba8035d0239051f01e4bdc7af5326a1d980.tar.xz
snac2-b1ecaba8035d0239051f01e4bdc7af5326a1d980.zip
Added a special drop for Delete messages from unknown actors.
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/activitypub.c b/activitypub.c
index 4f109cc..55a245e 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -1470,9 +1470,11 @@ int update_question(snac *user, const char *id)
1470 1470
1471int process_input_message(snac *snac, xs_dict *msg, xs_dict *req) 1471int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
1472/* processes an ActivityPub message from the input queue */ 1472/* processes an ActivityPub message from the input queue */
1473/* return values: -1, fatal error; 0, transient error, retry;
1474 1, processed and done; 2, propagate to users (only when no user is set) */
1473{ 1475{
1474 char *actor = xs_dict_get(msg, "actor"); 1476 char *actor = xs_dict_get(msg, "actor");
1475 char *type = xs_dict_get(msg, "type"); 1477 char *type = xs_dict_get(msg, "type");
1476 xs *actor_o = NULL; 1478 xs *actor_o = NULL;
1477 int a_status; 1479 int a_status;
1478 int do_notify = 0; 1480 int do_notify = 0;
@@ -1500,13 +1502,21 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
1500 else 1502 else
1501 utype = "(null)"; 1503 utype = "(null)";
1502 1504
1505 /* special case for Delete messages */
1506 if (strcmp(type, "Delete") == 0) {
1507 /* if the actor is not here, do not even try */
1508 if (!object_here(actor)) {
1509 srv_debug(0, xs_fmt("dropped 'Delete' message from unknown actor '%s'", actor));
1510 return -1;
1511 }
1512 }
1513
1503 /* bring the actor */ 1514 /* bring the actor */
1504 a_status = actor_request(actor, &actor_o); 1515 a_status = actor_request(actor, &actor_o);
1505 1516
1506 /* do not retry permanent failures */ 1517 /* do not retry permanent failures */
1507 if (a_status == 404 || a_status == 410 || a_status < 0) { 1518 if (a_status == 404 || a_status == 410 || a_status < 0) {
1508 srv_debug(1, xs_fmt("dropping message due to actor error %s %d", actor, a_status)); 1519 srv_debug(1, xs_fmt("dropping message due to actor error %s %d", actor, a_status));
1509
1510 return -1; 1520 return -1;
1511 } 1521 }
1512 1522
@@ -1519,7 +1529,6 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
1519 1529
1520 /* other actor download errors may need a retry */ 1530 /* other actor download errors may need a retry */
1521 srv_debug(1, xs_fmt("error requesting actor %s %d -- retry later", actor, a_status)); 1531 srv_debug(1, xs_fmt("error requesting actor %s %d -- retry later", actor, a_status));
1522
1523 return 0; 1532 return 0;
1524 } 1533 }
1525 1534
@@ -1530,13 +1539,12 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
1530 srv_log(xs_fmt("bad signature %s (%s)", actor, sig_err)); 1539 srv_log(xs_fmt("bad signature %s (%s)", actor, sig_err));
1531 1540
1532 srv_archive_error("check_signature", sig_err, req, msg); 1541 srv_archive_error("check_signature", sig_err, req, msg);
1533
1534 return -1; 1542 return -1;
1535 } 1543 }
1536 1544
1537 /* if no user is set, no further checks can be done */ 1545 /* if no user is set, no further checks can be done; propagate */
1538 if (snac == NULL) 1546 if (snac == NULL)
1539 return 1; 1547 return 2;
1540 1548
1541 /* reject messages that are not for this user */ 1549 /* reject messages that are not for this user */
1542 if (!is_msg_for_me(snac, msg)) { 1550 if (!is_msg_for_me(snac, msg)) {