diff options
| author | default <nobody@localhost> | 2025-03-13 12:51:40 +0100 |
|---|---|---|
| committer | default <nobody@localhost> | 2025-03-13 12:51:40 +0100 |
| commit | 60ddd6e6c77534cff0e778d577f61bb8c678567f (patch) | |
| tree | 1c0233df20bce1f35218f9786a1674b1fd0f240b /activitypub.c | |
| parent | a8ff65286e5d21b3ec254d4574244b3375ea0cce (diff) | |
Improved Undo+Follow logic (contributed by rozenglass).
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/activitypub.c b/activitypub.c index c9f700f..c00c371 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2180,25 +2180,32 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req) if (strcmp(type, "Undo") == 0) { /** **/ const char *id = xs_dict_get(object, "object"); - if (xs_type(object) != XSTYPE_DICT) + if (xs_type(object) != XSTYPE_DICT) { + snac_debug(snac, 1, xs_fmt("undo: overriding utype %s | %s | %s", + utype, id, actor)); utype = "Follow"; + } if (strcmp(utype, "Follow") == 0) { /** **/ - if (id && strcmp(id, snac->actor) != 0) + if (!id) { + snac_log(snac, xs_fmt("no id (msg.object.object) when " + "handling follow: %s", actor)); + return 1; + } + if (strcmp(id, snac->actor) != 0) snac_debug(snac, 1, xs_fmt("Undo + Follow from %s not for us (%s)", actor, id)); - else { - if (valid_status(follower_del(snac, actor))) { - snac_log(snac, xs_fmt("no longer following us %s", actor)); - do_notify = 1; - } - else - if (pending_check(snac, actor)) { - pending_del(snac, actor); - snac_log(snac, xs_fmt("cancelled pending follow from %s", actor)); - } - else - snac_log(snac, xs_fmt("error deleting follower %s", actor)); + else + if (valid_status(follower_del(snac, actor))) { + snac_log(snac, xs_fmt("no longer following us %s", actor)); + do_notify = 1; } + else + if (pending_check(snac, actor)) { + pending_del(snac, actor); + snac_log(snac, xs_fmt("cancelled pending follow from %s", actor)); + } + else + snac_log(snac, xs_fmt("error deleting follower %s", actor)); } else if (strcmp(utype, "Like") == 0 || strcmp(utype, "EmojiReact") == 0) { /** **/ |