summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2024-05-06 05:54:46 +0200
committerGravatar default2024-05-06 05:54:46 +0200
commitc884f7081ab679014d05ebb6ad6add2315584e84 (patch)
tree090c7d5af9e8cc8f339df6cf9e085a0f0e4082da
parentMinor RSS title beautifying. (diff)
downloadsnac2-c884f7081ab679014d05ebb6ad6add2315584e84.tar.gz
snac2-c884f7081ab679014d05ebb6ad6add2315584e84.tar.xz
snac2-c884f7081ab679014d05ebb6ad6add2315584e84.zip
mastoapi: also fix polls from Pleroma.
-rw-r--r--mastoapi.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 0cdb4bf..e435ce9 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -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));