summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/html.c b/html.c
index 99da2f7..7d67039 100644
--- a/html.c
+++ b/html.c
@@ -729,7 +729,7 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
729 return xs_str_cat(os, s); 729 return xs_str_cat(os, s);
730 } 730 }
731 else 731 else
732 if (strcmp(type, "Note") != 0) { 732 if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0) {
733 /* skip oddities */ 733 /* skip oddities */
734 return os; 734 return os;
735 } 735 }
@@ -881,6 +881,37 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
881 } 881 }
882 } 882 }
883 883
884 if (strcmp(type, "Question") == 0) {
885 xs_list *oo = xs_dict_get(msg, "oneOf");
886 xs_list *ao = xs_dict_get(msg, "anyOf");
887 xs_list *p;
888 xs_dict *v;
889
890 p = oo != NULL ? oo : ao;
891
892 if (!xs_is_null(xs_dict_get(msg, "closed"))) {
893 /* closed poll */
894 c = xs_str_cat(c, "<table>\n");
895
896 while (xs_list_iter(&p, &v)) {
897 const char *name = xs_dict_get(v, "name");
898 const xs_dict *replies = xs_dict_get(v, "replies");
899
900 if (name && replies) {
901 int nr = xs_number_get(xs_dict_get(replies, "totalItems"));
902 xs *l = xs_fmt("<tr><td>%s:</td><td>%d</td></tr>\n", name, nr);
903
904 c = xs_str_cat(c, l);
905 }
906 }
907
908 c = xs_str_cat(c, "</table>\n");
909 }
910 else {
911 /* poll still active */
912 }
913 }
914
884 s = xs_str_cat(s, c); 915 s = xs_str_cat(s, c);
885 } 916 }
886 917