summaryrefslogtreecommitdiff
path: root/html.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 /html.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 'html.c')
-rw-r--r--html.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/html.c b/html.c
index 9dc42df..4abfa37 100644
--- a/html.c
+++ b/html.c
@@ -853,6 +853,14 @@ xs_html *html_top_controls(snac *snac)
if (xs_is_null(telegram_chat_id))
telegram_chat_id = "";
+ char *ntfy_server = xs_dict_get(snac->config, "ntfy_server");
+ if (xs_is_null(ntfy_server))
+ ntfy_server = "";
+
+ char *ntfy_token = xs_dict_get(snac->config, "ntfy_token");
+ if (xs_is_null(ntfy_token))
+ ntfy_token = "";
+
char *purge_days = xs_dict_get(snac->config, "purge_days");
if (!xs_is_null(purge_days) && xs_type(purge_days) == XSTYPE_NUMBER)
purge_days = (char *)xs_number_str(purge_days);
@@ -947,6 +955,20 @@ xs_html *html_top_controls(snac *snac)
xs_html_attr("value", telegram_chat_id),
xs_html_attr("placeholder", "Chat id"))),
xs_html_tag("p",
+ xs_html_text(L("ntfy notifications (ntfy server and token):")),
+ xs_html_sctag("br", NULL),
+ xs_html_sctag("input",
+ xs_html_attr("type", "text"),
+ xs_html_attr("name", "ntfy_server"),
+ xs_html_attr("value", ntfy_server),
+ xs_html_attr("placeholder", "ntfy server - full URL (example: https://ntfy.sh/YourTopic)")),
+ xs_html_text(" "),
+ xs_html_sctag("input",
+ xs_html_attr("type", "text"),
+ xs_html_attr("name", "ntfy_token"),
+ xs_html_attr("value", ntfy_token),
+ xs_html_attr("placeholder", "ntfy token - if needed"))),
+ xs_html_tag("p",
xs_html_text(L("Maximum days to keep posts (0: server settings):")),
xs_html_sctag("br", NULL),
xs_html_sctag("input",
@@ -2890,6 +2912,10 @@ int html_post_handler(const xs_dict *req, const char *q_path,
snac.config = xs_dict_set(snac.config, "telegram_bot", v);
if ((v = xs_dict_get(p_vars, "telegram_chat_id")) != NULL)
snac.config = xs_dict_set(snac.config, "telegram_chat_id", v);
+ if ((v = xs_dict_get(p_vars, "ntfy_server")) != NULL)
+ snac.config = xs_dict_set(snac.config, "ntfy_server", v);
+ if ((v = xs_dict_get(p_vars, "ntfy_token")) != NULL)
+ snac.config = xs_dict_set(snac.config, "ntfy_token", v);
if ((v = xs_dict_get(p_vars, "purge_days")) != NULL) {
xs *days = xs_number_new(atof(v));
snac.config = xs_dict_set(snac.config, "purge_days", days);