diff options
author | grunfink <grunfink@noreply.codeberg.org> | 2024-01-12 17:09:58 +0000 |
---|---|---|
committer | grunfink <grunfink@noreply.codeberg.org> | 2024-01-12 17:09:58 +0000 |
commit | a0cb5c60cdbf7855fa0c2842113797be2a206226 (patch) | |
tree | 3cff6166192f8bc8f34149a0a18ca103cfb1384e /html.c | |
parent | d8e7fe69eda030b960bda8eecfdcc126a09ce14f (diff) | |
parent | 82d57557bb9a16f18ed5acc874d283ef0e9f47f5 (diff) |
Merge pull request 'Added support for ntfy notifications with enhanced privacy when utilizing a self-hosted server, eliminating the need for external services.' (#102) from draga79/snac2:master into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/102
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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); |