commit c55a2e4
default
·
2023-05-31 20:10:45 +0000 UTC
parent 3b72b0f
Don't notify about closed polls that we didn't vote for.
1 files changed,
+10,
-2
+10,
-2
1@@ -489,6 +489,8 @@ void process_tags(snac *snac, const char *content, xs_str **n_content, xs_list *
2 void notify(snac *snac, const char *type, const char *utype, const char *actor, const xs_dict *msg)
3 /* notifies the user of relevant events */
4 {
5+ const char *id = xs_dict_get(msg, "id");
6+
7 if (strcmp(type, "Create") == 0) {
8 /* only notify of notes specifically for us */
9 xs *rcpts = recipient_list(snac, msg, 0);
10@@ -510,7 +512,7 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor,
11 if (xs_type(objid) == XSTYPE_DICT)
12 objid = xs_dict_get(objid, "id");
13 else
14- objid = xs_dict_get(msg, "id");
15+ objid = id;
16
17 if (strcmp(type, "Like") == 0 || strcmp(type, "Announce") == 0) {
18 /* if it's not an admiration about something by us, done */
19@@ -518,6 +520,12 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor,
20 return;
21 }
22
23+ /* if it's a closed poll but we didn't vote, drop it */
24+ if (strcmp(type, "Update") == 0 && strcmp(type, "Question") == 0) {
25+ if (!was_question_voted(snac, id))
26+ return;
27+ }
28+
29 /* user will love to know about this! */
30
31 /* prepare message body */
32@@ -587,7 +595,7 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor,
33
34 /* finally, store it in the notification folder */
35 if (strcmp(type, "Follow") == 0)
36- objid = xs_dict_get(msg, "id");
37+ objid = id;
38
39 notify_add(snac, type, utype, actor, objid);
40 }