diff options
| author | 2023-05-24 13:19:40 +0200 | |
|---|---|---|
| committer | 2023-05-24 13:19:40 +0200 | |
| commit | 6eb0aa105ad883ecb541aafa931c30dd48a14cc3 (patch) | |
| tree | c5480d871aaecf5378e5d12bc4a7e1e822a474c8 /html.c | |
| parent | More prototype tunnings. (diff) | |
| download | snac2-6eb0aa105ad883ecb541aafa931c30dd48a14cc3.tar.gz snac2-6eb0aa105ad883ecb541aafa931c30dd48a14cc3.tar.xz snac2-6eb0aa105ad883ecb541aafa931c30dd48a14cc3.zip | |
Show the poll as closed if we already voted for it.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 22 |
1 files changed, 21 insertions, 1 deletions
| @@ -896,10 +896,30 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local, | |||
| 896 | xs_list *ao = xs_dict_get(msg, "anyOf"); | 896 | xs_list *ao = xs_dict_get(msg, "anyOf"); |
| 897 | xs_list *p; | 897 | xs_list *p; |
| 898 | xs_dict *v; | 898 | xs_dict *v; |
| 899 | int closed = 0; | ||
| 899 | 900 | ||
| 901 | if (xs_dict_get(msg, "closed")) | ||
| 902 | closed = 1; | ||
| 903 | else { | ||
| 904 | /* not yet closed? check if we already voted for this */ | ||
| 905 | xs *children = object_children(id); | ||
| 906 | p = children; | ||
| 907 | while (!closed && xs_list_iter(&p, &v)) { | ||
| 908 | xs *msg = NULL; | ||
| 909 | |||
| 910 | if (valid_status(object_get_by_md5(v, &msg))) { | ||
| 911 | const char *atto = xs_dict_get(msg, "attributedTo"); | ||
| 912 | |||
| 913 | if (atto && strcmp(atto, snac->actor) == 0) | ||
| 914 | closed = 1; /* closed for us */ | ||
| 915 | } | ||
| 916 | } | ||
| 917 | } | ||
| 918 | |||
| 919 | /* get the appropriate list of options */ | ||
| 900 | p = oo != NULL ? oo : ao; | 920 | p = oo != NULL ? oo : ao; |
| 901 | 921 | ||
| 902 | if (!xs_is_null(xs_dict_get(msg, "closed"))) { | 922 | if (closed) { |
| 903 | /* closed poll */ | 923 | /* closed poll */ |
| 904 | c = xs_str_cat(c, "<table>\n"); | 924 | c = xs_str_cat(c, "<table>\n"); |
| 905 | 925 | ||