diff options
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 18 |
1 files changed, 2 insertions, 16 deletions
| @@ -598,7 +598,6 @@ xs_dict *mastoapi_poll(snac *snac, const xs_dict *msg) | |||
| 598 | xs *f = xs_val_new(XSTYPE_FALSE); | 598 | xs *f = xs_val_new(XSTYPE_FALSE); |
| 599 | xs *t = xs_val_new(XSTYPE_TRUE); | 599 | xs *t = xs_val_new(XSTYPE_TRUE); |
| 600 | xs_list *opts = NULL; | 600 | xs_list *opts = NULL; |
| 601 | xs_list *p; | ||
| 602 | xs_val *v; | 601 | xs_val *v; |
| 603 | int num_votes = 0; | 602 | int num_votes = 0; |
| 604 | xs *options = xs_list_new(); | 603 | xs *options = xs_list_new(); |
| @@ -638,21 +637,8 @@ xs_dict *mastoapi_poll(snac *snac, const xs_dict *msg) | |||
| 638 | xs *vc = xs_number_new(num_votes); | 637 | xs *vc = xs_number_new(num_votes); |
| 639 | poll = xs_dict_append(poll, "votes_count", vc); | 638 | poll = xs_dict_append(poll, "votes_count", vc); |
| 640 | 639 | ||
| 641 | xs *children = object_children(xs_dict_get(msg, "id")); | 640 | poll = xs_dict_append(poll, "voted", |
| 642 | int voted = 0; | 641 | was_question_voted(snac, xs_dict_get(msg, "id")) ? t : f); |
| 643 | p = children; | ||
| 644 | while (xs_list_iter(&p, &v)) { | ||
| 645 | xs *obj = NULL; | ||
| 646 | |||
| 647 | if (valid_status(object_get_by_md5(v, &obj))) { | ||
| 648 | if (strcmp(xs_dict_get(obj, "attributedTo"), snac->actor) == 0) { | ||
| 649 | voted = 1; | ||
| 650 | break; | ||
| 651 | } | ||
| 652 | } | ||
| 653 | } | ||
| 654 | |||
| 655 | poll = xs_dict_append(poll, "voted", voted ? t : f); | ||
| 656 | } | 642 | } |
| 657 | 643 | ||
| 658 | return poll; | 644 | return poll; |