diff options
author | default <nobody@localhost> | 2022-10-21 10:36:09 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2022-10-21 10:36:09 +0200 |
commit | d210674569d203650f71bccdb2f718731388dcf1 (patch) | |
tree | 3da2e1d2bd13a3222c43f37b1352756ef64f1362 /activitypub.c | |
parent | 6e470440f9971d0a2b63286215e2b019a8a7f802 (diff) |
Don't notify about admirations of things by others.
Diffstat (limited to 'activitypub.c')
-rw-r--r-- | activitypub.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/activitypub.c b/activitypub.c index f154515..f12aa47 100644 --- a/activitypub.c +++ b/activitypub.c @@ -631,7 +631,8 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char void notify(snac *snac, char *type, char *utype, char *actor, char *msg) /* notifies the user of relevant events */ { - char *email = xs_dict_get(snac->config, "email"); + char *email = xs_dict_get(snac->config, "email"); + char *object = NULL; /* no email address? done */ if (xs_is_null(email) || *email == '\0') @@ -648,6 +649,21 @@ void notify(snac *snac, char *type, char *utype, char *actor, char *msg) if (strcmp(type, "Undo") == 0 && strcmp(utype, "Follow") != 0) return; + if (strcmp(type, "Like") == 0 || strcmp(type, "Announce") == 0) { + object = xs_str_get(msg, "object"); + + if (xs_is_null(object)) + return; + else { + if (xs_type(object) == XSTYPE_DICT) + object = xs_dict_get(object, "id"); + + /* if it's not an admiration about something by us, done */ + if (xs_is_null(object) || !xs_startswith(object, snac->actor)) + return; + } + } + snac_debug(snac, 1, xs_fmt("notify(%s, %s, %s)", type, utype, actor)); /* prepare message */ @@ -678,19 +694,9 @@ void notify(snac *snac, char *type, char *utype, char *actor, char *msg) body = xs_str_cat(body, s1); } - if (strcmp(type, "Like") == 0 || strcmp(type, "Announce") == 0) { - /* there is a related object: add it */ - char *object = xs_dict_get(msg, "object"); - - if (!xs_is_null(object)) { - if (xs_type(object) == XSTYPE_DICT) - object = xs_dict_get(object, "id"); - - if (!xs_is_null(object)) { - xs *s1 = xs_fmt("Object: %s\n", object); - body = xs_str_cat(body, s1); - } - } + if (object != NULL) { + xs *s1 = xs_fmt("Object: %s\n", object); + body = xs_str_cat(body, s1); } /* now write */ |