diff options
| -rw-r--r-- | mastoapi.c | 17 |
1 files changed, 15 insertions, 2 deletions
| @@ -716,10 +716,23 @@ xs_dict *mastoapi_poll(snac *snac, const xs_dict *msg) | |||
| 716 | xs *options = xs_list_new(); | 716 | xs *options = xs_list_new(); |
| 717 | 717 | ||
| 718 | poll = xs_dict_append(poll, "id", mid); | 718 | poll = xs_dict_append(poll, "id", mid); |
| 719 | xs *fd = mastoapi_date(xs_dict_get(msg, "endTime")); | 719 | char *date = xs_dict_get(msg, "endTime"); |
| 720 | if (date == NULL) | ||
| 721 | date = xs_dict_get(msg, "closed"); | ||
| 722 | if (date == NULL) | ||
| 723 | return NULL; | ||
| 724 | |||
| 725 | xs *fd = mastoapi_date(date); | ||
| 720 | poll = xs_dict_append(poll, "expires_at", fd); | 726 | poll = xs_dict_append(poll, "expires_at", fd); |
| 727 | |||
| 728 | date = xs_dict_get(msg, "closed"); | ||
| 729 | time_t t = 0; | ||
| 730 | |||
| 731 | if (date != NULL) | ||
| 732 | t = xs_parse_iso_date(date, 0); | ||
| 733 | |||
| 721 | poll = xs_dict_append(poll, "expired", | 734 | poll = xs_dict_append(poll, "expired", |
| 722 | xs_dict_get(msg, "closed") != NULL ? xs_stock(XSTYPE_TRUE) : xs_stock(XSTYPE_FALSE)); | 735 | t < time(NULL) ? xs_stock(XSTYPE_FALSE) : xs_stock(XSTYPE_TRUE)); |
| 723 | 736 | ||
| 724 | if ((opts = xs_dict_get(msg, "oneOf")) != NULL) | 737 | if ((opts = xs_dict_get(msg, "oneOf")) != NULL) |
| 725 | poll = xs_dict_append(poll, "multiple", xs_stock(XSTYPE_FALSE)); | 738 | poll = xs_dict_append(poll, "multiple", xs_stock(XSTYPE_FALSE)); |