From 2af94818377740dad047e1f3c85ce03a3e865ffe Mon Sep 17 00:00:00 2001 From: Stefano Marinelli Date: Fri, 12 Jan 2024 09:54:14 +0100 Subject: Added support for ntfy notifications. You can configure either a self-hosted server or use the official ntfy.sh, and you have the option to use a private token to protect access and topics. --- data.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'data.c') diff --git a/data.c b/data.c index 5e2f43d..97cd94f 100644 --- a/data.c +++ b/data.c @@ -2232,6 +2232,21 @@ void enqueue_telegram(const xs_str *msg, const char *bot, const char *chat_id) srv_debug(1, xs_fmt("enqueue_telegram %s %s", bot, chat_id)); } +void enqueue_ntfy(const xs_str *msg, const char *ntfy_server, const char *ntfy_token) +/* enqueues a message to be sent via ntfy */ +{ + xs *qmsg = _new_qmsg("ntfy", msg, 0); + char *ntid = xs_dict_get(qmsg, "ntid"); + xs *fn = xs_fmt("%s/queue/%s.json", srv_basedir, ntid); + + qmsg = xs_dict_append(qmsg, "ntfy_server", ntfy_server); + qmsg = xs_dict_append(qmsg, "ntfy_token", ntfy_token); + + + qmsg = _enqueue_put(fn, qmsg); + + srv_debug(1, xs_fmt("enqueue_ntfy %s %s", ntfy_server, ntfy_token)); +} void enqueue_message(snac *snac, const xs_dict *msg) /* enqueues an output message */ -- cgit v1.2.3