summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorGravatar default2022-10-21 19:07:20 +0200
committerGravatar default2022-10-21 19:07:20 +0200
commit084731fec24932ad48c48c5147d129ce2af0ccc8 (patch)
treeb8f733e0419fb5ea851a5030273b5e3cff808b10 /data.c
parentVersion 2.06 RELEASED. (diff)
downloadsnac2-084731fec24932ad48c48c5147d129ce2af0ccc8.tar.gz
snac2-084731fec24932ad48c48c5147d129ce2af0ccc8.tar.xz
snac2-084731fec24932ad48c48c5147d129ce2af0ccc8.zip
Send notification emails through the queue.
Diffstat (limited to 'data.c')
-rw-r--r--data.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/data.c b/data.c
index cef4028..7b623af 100644
--- a/data.c
+++ b/data.c
@@ -980,6 +980,25 @@ void enqueue_output(snac *snac, char *msg, char *actor, int retries)
980} 980}
981 981
982 982
983void enqueue_email(snac *snac, char *msg, int retries)
984/* enqueues an email message to be sent */
985{
986 int qrt = xs_number_get(xs_dict_get(srv_config, "queue_retry_minutes"));
987 xs *ntid = tid(retries * 60 * qrt);
988 xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
989 xs *qmsg = xs_dict_new();
990 xs *rn = xs_number_new(retries);
991
992 qmsg = xs_dict_append(qmsg, "type", "email");
993 qmsg = xs_dict_append(qmsg, "message", msg);
994 qmsg = xs_dict_append(qmsg, "retries", rn);
995
996 _enqueue_put(fn, qmsg);
997
998 snac_debug(snac, 1, xs_fmt("enqueue_email %d", retries));
999}
1000
1001
983d_char *queue(snac *snac) 1002d_char *queue(snac *snac)
984/* returns a list with filenames that can be dequeued */ 1003/* returns a list with filenames that can be dequeued */
985{ 1004{
@@ -997,7 +1016,7 @@ d_char *queue(snac *snac)
997 time_t t2 = atol(bn + 1); 1016 time_t t2 = atol(bn + 1);
998 1017
999 if (t2 > t) 1018 if (t2 > t)
1000 snac_debug(snac, 2, xs_fmt("queue not yet time for %s", v)); 1019 snac_debug(snac, 2, xs_fmt("queue not yet time for %s [%ld]", v, t));
1001 else { 1020 else {
1002 list = xs_list_append(list, v); 1021 list = xs_list_append(list, v);
1003 snac_debug(snac, 2, xs_fmt("queue ready for %s", v)); 1022 snac_debug(snac, 2, xs_fmt("queue ready for %s", v));