From 765936244888f8d5f1644b0178cc6dc70597166b Mon Sep 17 00:00:00 2001 From: default Date: Mon, 29 May 2023 11:07:38 +0200 Subject: Enqueue a close_question user q_item. --- activitypub.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 27f9c7c..15937c3 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1058,8 +1058,10 @@ int update_question(snac *user, const char *id) xs *now = xs_str_utctime(0, ISO_DATE_SPEC); /* it's now greater than the endTime? */ - if (strcmp(now, end_time) > 0) - msg = xs_dict_set(msg, "closed", end_time); + if (strcmp(now, end_time) > 0) { + xs *et = xs_dup(end_time); + msg = xs_dict_set(msg, "closed", et); + } } /* update the count of voters */ @@ -1540,6 +1542,14 @@ void process_user_queue_item(snac *snac, xs_dict *q_item) } } } + else + if (strcmp(type, "close_question") == 0) { + /* the time for this question has ended */ + const char *id = xs_dict_get(q_item, "message"); + + if (!xs_is_null(id)) + update_question(snac, id); + } else snac_log(snac, xs_fmt("unexpected q_item type '%s'", type)); } -- cgit v1.2.3