diff options
| -rw-r--r-- | html.c | 19 |
1 files changed, 19 insertions, 0 deletions
| @@ -307,6 +307,10 @@ d_char *html_top_controls(snac *snac, d_char *s) | |||
| 307 | "<input type=\"text\" name=\"email\" value=\"%s\"></p>\n" | 307 | "<input type=\"text\" name=\"email\" value=\"%s\"></p>\n" |
| 308 | 308 | ||
| 309 | "<p>%s:<br>\n" | 309 | "<p>%s:<br>\n" |
| 310 | "<input type=\"text\" name=\"telegram_bot\" placeholder=\"Bot API key\" value=\"%s\"> " | ||
| 311 | "<input type=\"text\" name=\"telegram_chat_id\" placeholder=\"Chat id\" value=\"%s\"></p>\n" | ||
| 312 | |||
| 313 | "<p>%s:<br>\n" | ||
| 310 | "<input type=\"number\" name=\"purge_days\" value=\"%s\"></p>\n" | 314 | "<input type=\"number\" name=\"purge_days\" value=\"%s\"></p>\n" |
| 311 | 315 | ||
| 312 | "<p>%s:<br>\n" | 316 | "<p>%s:<br>\n" |
| @@ -332,6 +336,14 @@ d_char *html_top_controls(snac *snac, d_char *s) | |||
| 332 | if (xs_is_null(cw)) | 336 | if (xs_is_null(cw)) |
| 333 | cw = ""; | 337 | cw = ""; |
| 334 | 338 | ||
| 339 | char *telegram_bot = xs_dict_get(snac->config, "telegram_bot"); | ||
| 340 | if (xs_is_null(telegram_bot)) | ||
| 341 | telegram_bot = ""; | ||
| 342 | |||
| 343 | char *telegram_chat_id = xs_dict_get(snac->config, "telegram_chat_id"); | ||
| 344 | if (xs_is_null(telegram_chat_id)) | ||
| 345 | telegram_chat_id = ""; | ||
| 346 | |||
| 335 | const char *purge_days = xs_dict_get(snac->config, "purge_days"); | 347 | const char *purge_days = xs_dict_get(snac->config, "purge_days"); |
| 336 | if (!xs_is_null(purge_days) && xs_type(purge_days) == XSTYPE_NUMBER) | 348 | if (!xs_is_null(purge_days) && xs_type(purge_days) == XSTYPE_NUMBER) |
| 337 | purge_days = xs_number_str(purge_days); | 349 | purge_days = xs_number_str(purge_days); |
| @@ -364,6 +376,9 @@ d_char *html_top_controls(snac *snac, d_char *s) | |||
| 364 | L("Always show sensitive content"), | 376 | L("Always show sensitive content"), |
| 365 | L("Email address for notifications"), | 377 | L("Email address for notifications"), |
| 366 | email, | 378 | email, |
| 379 | L("Telegram notifications (bot key and chat id)"), | ||
| 380 | telegram_bot, | ||
| 381 | telegram_chat_id, | ||
| 367 | L("Maximum days to keep posts (0: server settings)"), | 382 | L("Maximum days to keep posts (0: server settings)"), |
| 368 | purge_days, | 383 | purge_days, |
| 369 | L("Password (only to change it)"), | 384 | L("Password (only to change it)"), |
| @@ -1578,6 +1593,10 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, | |||
| 1578 | } | 1593 | } |
| 1579 | if ((v = xs_dict_get(p_vars, "email")) != NULL) | 1594 | if ((v = xs_dict_get(p_vars, "email")) != NULL) |
| 1580 | snac.config = xs_dict_set(snac.config, "email", v); | 1595 | snac.config = xs_dict_set(snac.config, "email", v); |
| 1596 | if ((v = xs_dict_get(p_vars, "telegram_bot")) != NULL) | ||
| 1597 | snac.config = xs_dict_set(snac.config, "telegram_bot", v); | ||
| 1598 | if ((v = xs_dict_get(p_vars, "telegram_chat_id")) != NULL) | ||
| 1599 | snac.config = xs_dict_set(snac.config, "telegram_chat_id", v); | ||
| 1581 | if ((v = xs_dict_get(p_vars, "purge_days")) != NULL) { | 1600 | if ((v = xs_dict_get(p_vars, "purge_days")) != NULL) { |
| 1582 | xs *days = xs_number_new(atof(v)); | 1601 | xs *days = xs_number_new(atof(v)); |
| 1583 | snac.config = xs_dict_set(snac.config, "purge_days", days); | 1602 | snac.config = xs_dict_set(snac.config, "purge_days", days); |