summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-07-24 20:44:00 +0200
committerdefault <nobody@localhost>2023-07-24 20:44:00 +0200
commite428b5786524c5aea625f14cae14e86d6753e5d2 (patch)
tree7d4b4480aab579b214f3e468c0f7472b38b4c2e1
parentdc5c1ce0ac7ef39864a2346bebc6e6ecdb519dc5 (diff)
Improved Accept + implicit Follow code.
-rw-r--r--activitypub.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/activitypub.c b/activitypub.c
index 27cf786..2bb94fe 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -1512,7 +1512,18 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
}
else
if (strcmp(type, "Accept") == 0) { /** **/
- if (strcmp(utype, "Follow") == 0 || strcmp(utype, "(null)") == 0) { /** **/
+ if (strcmp(utype, "(null)") == 0) {
+ const char *obj_id = xs_dict_get(msg, "object");
+
+ /* if the accepted object id is a string that may
+ be created by us, it's a follow */
+ if (xs_type(obj_id) == XSTYPE_STRING &&
+ xs_startswith(obj_id, srv_baseurl) &&
+ xs_endswith(obj_id, "/Follow"))
+ utype = "Follow";
+ }
+
+ if (strcmp(utype, "Follow") == 0) { /** **/
if (following_check(snac, actor)) {
following_add(snac, actor, msg);
snac_log(snac, xs_fmt("confirmed follow from %s", actor));