From c55a2e4d136995eb538ae1675d6478e4c3028e12 Mon Sep 17 00:00:00 2001 From: default Date: Wed, 31 May 2023 22:10:45 +0200 Subject: [PATCH] Don't notify about closed polls that we didn't vote for. --- activitypub.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/activitypub.c b/activitypub.c index f9bd9ab..4d873e7 100644 --- a/activitypub.c +++ b/activitypub.c @@ -489,6 +489,8 @@ void process_tags(snac *snac, const char *content, xs_str **n_content, xs_list * void notify(snac *snac, const char *type, const char *utype, const char *actor, const xs_dict *msg) /* notifies the user of relevant events */ { + const char *id = xs_dict_get(msg, "id"); + if (strcmp(type, "Create") == 0) { /* only notify of notes specifically for us */ xs *rcpts = recipient_list(snac, msg, 0); @@ -510,7 +512,7 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor, if (xs_type(objid) == XSTYPE_DICT) objid = xs_dict_get(objid, "id"); else - objid = xs_dict_get(msg, "id"); + objid = id; if (strcmp(type, "Like") == 0 || strcmp(type, "Announce") == 0) { /* if it's not an admiration about something by us, done */ @@ -518,6 +520,12 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor, return; } + /* if it's a closed poll but we didn't vote, drop it */ + if (strcmp(type, "Update") == 0 && strcmp(type, "Question") == 0) { + if (!was_question_voted(snac, id)) + return; + } + /* user will love to know about this! */ /* prepare message body */ @@ -587,7 +595,7 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor, /* finally, store it in the notification folder */ if (strcmp(type, "Follow") == 0) - objid = xs_dict_get(msg, "id"); + objid = id; notify_add(snac, type, utype, actor, objid); }