summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorStefano Marinelli <stefano@dragas.it>2024-01-12 09:54:14 +0100
committerStefano Marinelli <stefano@dragas.it>2024-01-12 09:54:14 +0100
commit2af94818377740dad047e1f3c85ce03a3e865ffe (patch)
tree0c6717f64f77acae046b85edae379b9e18fb78fc /data.c
parentadf5623044f7dcd84edb8345595a1bda651e5cbb (diff)
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.
Diffstat (limited to 'data.c')
-rw-r--r--data.c15
1 files changed, 15 insertions, 0 deletions
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 */