diff options
author | default <nobody@localhost> | 2024-05-06 05:54:46 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2024-05-06 05:54:46 +0200 |
commit | c884f7081ab679014d05ebb6ad6add2315584e84 (patch) | |
tree | 090c7d5af9e8cc8f339df6cf9e085a0f0e4082da /mastoapi.c | |
parent | c31a4ae73e9759cebda2a9cf8a34b352dc246314 (diff) |
mastoapi: also fix polls from Pleroma.
Diffstat (limited to 'mastoapi.c')
-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) xs *options = xs_list_new(); poll = xs_dict_append(poll, "id", mid); - xs *fd = mastoapi_date(xs_dict_get(msg, "endTime")); + char *date = xs_dict_get(msg, "endTime"); + if (date == NULL) + date = xs_dict_get(msg, "closed"); + if (date == NULL) + return NULL; + + xs *fd = mastoapi_date(date); poll = xs_dict_append(poll, "expires_at", fd); + + date = xs_dict_get(msg, "closed"); + time_t t = 0; + + if (date != NULL) + t = xs_parse_iso_date(date, 0); + poll = xs_dict_append(poll, "expired", - xs_dict_get(msg, "closed") != NULL ? xs_stock(XSTYPE_TRUE) : xs_stock(XSTYPE_FALSE)); + t < time(NULL) ? xs_stock(XSTYPE_FALSE) : xs_stock(XSTYPE_TRUE)); if ((opts = xs_dict_get(msg, "oneOf")) != NULL) poll = xs_dict_append(poll, "multiple", xs_stock(XSTYPE_FALSE)); |