diff options
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/activitypub.c b/activitypub.c index a906463..da64573 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -970,10 +970,11 @@ xs_dict *msg_question(snac *user, const char *content, const xs_list *opts, int | |||
| 970 | int update_question(snac *user, const char *id) | 970 | int update_question(snac *user, const char *id) |
| 971 | /* updates the poll counts */ | 971 | /* updates the poll counts */ |
| 972 | { | 972 | { |
| 973 | xs *msg = NULL; | 973 | xs *msg = NULL; |
| 974 | xs *rcnt = xs_dict_new(); | 974 | xs *rcnt = xs_dict_new(); |
| 975 | xs *z = xs_number_new(0); | 975 | xs *z = xs_number_new(0); |
| 976 | xs *chld = NULL; | 976 | xs *chld = NULL; |
| 977 | xs *rcpts = xs_list_new(); | ||
| 977 | xs_list *opts; | 978 | xs_list *opts; |
| 978 | xs_val *p; | 979 | xs_val *p; |
| 979 | xs_str *k; | 980 | xs_str *k; |
| @@ -1010,7 +1011,9 @@ int update_question(snac *user, const char *id) | |||
| 1010 | continue; | 1011 | continue; |
| 1011 | 1012 | ||
| 1012 | const char *name = xs_dict_get(obj, "name"); | 1013 | const char *name = xs_dict_get(obj, "name"); |
| 1013 | if (name) { | 1014 | const char *atto = xs_dict_get(obj, "attributedTo"); |
| 1015 | |||
| 1016 | if (name && atto) { | ||
| 1014 | /* get the current count */ | 1017 | /* get the current count */ |
| 1015 | const xs_number *cnt = xs_dict_get(rcnt, name); | 1018 | const xs_number *cnt = xs_dict_get(rcnt, name); |
| 1016 | 1019 | ||
| @@ -1018,6 +1021,8 @@ int update_question(snac *user, const char *id) | |||
| 1018 | /* if it exists, increment */ | 1021 | /* if it exists, increment */ |
| 1019 | xs *ucnt = xs_number_new(xs_number_get(cnt) + 1); | 1022 | xs *ucnt = xs_number_new(xs_number_get(cnt) + 1); |
| 1020 | rcnt = xs_dict_set(rcnt, name, ucnt); | 1023 | rcnt = xs_dict_set(rcnt, name, ucnt); |
| 1024 | |||
| 1025 | rcpts = xs_list_append(rcpts, atto); | ||
| 1021 | } | 1026 | } |
| 1022 | } | 1027 | } |
| 1023 | } | 1028 | } |
| @@ -1058,6 +1063,12 @@ int update_question(snac *user, const char *id) | |||
| 1058 | snac_debug(user, 1, xs_fmt("recounted poll %s", id)); | 1063 | snac_debug(user, 1, xs_fmt("recounted poll %s", id)); |
| 1059 | timeline_touch(user); | 1064 | timeline_touch(user); |
| 1060 | 1065 | ||
| 1066 | /* send an update message to all voters */ | ||
| 1067 | xs *u_msg = msg_update(user, msg); | ||
| 1068 | u_msg = xs_dict_set(u_msg, "cc", rcpts); | ||
| 1069 | |||
| 1070 | enqueue_message(user, u_msg); | ||
| 1071 | |||
| 1061 | return 0; | 1072 | return 0; |
| 1062 | } | 1073 | } |
| 1063 | 1074 | ||