diff options
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 19 |
1 files changed, 16 insertions, 3 deletions
| @@ -1653,20 +1653,27 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1653 | xs_list *p; | 1653 | xs_list *p; |
| 1654 | xs_dict *v; | 1654 | xs_dict *v; |
| 1655 | int closed = 0; | 1655 | int closed = 0; |
| 1656 | char *f_closed = NULL; | ||
| 1656 | 1657 | ||
| 1657 | xs_html *poll = xs_html_tag("div", NULL); | 1658 | xs_html *poll = xs_html_tag("div", NULL); |
| 1658 | 1659 | ||
| 1659 | if (read_only) | 1660 | if (read_only) |
| 1660 | closed = 1; /* non-identified page; show as closed */ | 1661 | closed = 1; /* non-identified page; show as closed */ |
| 1661 | else | 1662 | else |
| 1662 | if (xs_dict_get(msg, "closed")) | ||
| 1663 | closed = 2; | ||
| 1664 | else | ||
| 1665 | if (user && xs_startswith(id, user->actor)) | 1663 | if (user && xs_startswith(id, user->actor)) |
| 1666 | closed = 1; /* we questioned; closed for us */ | 1664 | closed = 1; /* we questioned; closed for us */ |
| 1667 | else | 1665 | else |
| 1668 | if (user && was_question_voted(user, id)) | 1666 | if (user && was_question_voted(user, id)) |
| 1669 | closed = 1; /* we already voted; closed for us */ | 1667 | closed = 1; /* we already voted; closed for us */ |
| 1668 | else | ||
| 1669 | if ((f_closed = xs_dict_get(msg, "closed")) != NULL) { | ||
| 1670 | /* it has a closed date... but is it in the past? */ | ||
| 1671 | time_t t0 = time(NULL); | ||
| 1672 | time_t t1 = xs_parse_iso_date(f_closed, 0); | ||
| 1673 | |||
| 1674 | if (t1 < t0) | ||
| 1675 | closed = 2; | ||
| 1676 | } | ||
| 1670 | 1677 | ||
| 1671 | /* get the appropriate list of options */ | 1678 | /* get the appropriate list of options */ |
| 1672 | p = oo != NULL ? oo : ao; | 1679 | p = oo != NULL ? oo : ao; |
| @@ -1756,6 +1763,12 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1756 | else { | 1763 | else { |
| 1757 | /* show when the poll closes */ | 1764 | /* show when the poll closes */ |
| 1758 | char *end_time = xs_dict_get(msg, "endTime"); | 1765 | char *end_time = xs_dict_get(msg, "endTime"); |
| 1766 | |||
| 1767 | /* Pleroma does not have an endTime field; | ||
| 1768 | it has a closed time in the future */ | ||
| 1769 | if (xs_is_null(end_time)) | ||
| 1770 | end_time = xs_dict_get(msg, "closed"); | ||
| 1771 | |||
| 1759 | if (!xs_is_null(end_time)) { | 1772 | if (!xs_is_null(end_time)) { |
| 1760 | time_t t0 = time(NULL); | 1773 | time_t t0 = time(NULL); |
| 1761 | time_t t1 = xs_parse_iso_date(end_time, 0); | 1774 | time_t t1 = xs_parse_iso_date(end_time, 0); |