Add support for offline MUC notifications

This commit is contained in:
Stefan Ott
2022-04-14 04:25:30 +02:00
parent 652d30bb7f
commit 8044c82614
9 changed files with 63 additions and 1 deletions

View File

@@ -146,6 +146,7 @@ static Autocomplete notify_chat_ac;
static Autocomplete notify_room_ac;
static Autocomplete notify_typing_ac;
static Autocomplete notify_mention_ac;
static Autocomplete notify_offline_ac;
static Autocomplete notify_trigger_ac;
static Autocomplete prefs_ac;
static Autocomplete sub_ac;
@@ -344,6 +345,7 @@ cmd_ac_init(void)
autocomplete_add(notify_room_ac, "on");
autocomplete_add(notify_room_ac, "off");
autocomplete_add(notify_room_ac, "mention");
autocomplete_add(notify_room_ac, "offline");
autocomplete_add(notify_room_ac, "current");
autocomplete_add(notify_room_ac, "text");
autocomplete_add(notify_room_ac, "trigger");
@@ -361,6 +363,10 @@ cmd_ac_init(void)
autocomplete_add(notify_mention_ac, "word_whole");
autocomplete_add(notify_mention_ac, "word_part");
notify_offline_ac = autocomplete_new();
autocomplete_add(notify_offline_ac, "on");
autocomplete_add(notify_offline_ac, "off");
notify_trigger_ac = autocomplete_new();
autocomplete_add(notify_trigger_ac, "add");
autocomplete_add(notify_trigger_ac, "remove");
@@ -2338,6 +2344,11 @@ _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous
return result;
}
result = autocomplete_param_with_ac(input, "/notify room offline", notify_offline_ac, TRUE, previous);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/notify room trigger", notify_trigger_ac, TRUE, previous);
if (result) {
return result;

View File

@@ -1436,6 +1436,7 @@ static struct cmd_t command_defs[] = {
"/notify room mention on|off",
"/notify room mention case_sensitive|case_insensitive",
"/notify room mention word_whole|word_part",
"/notify room offline on|off",
"/notify room current on|off",
"/notify room text on|off",
"/notify room trigger add <text>",
@@ -1464,6 +1465,7 @@ static struct cmd_t command_defs[] = {
{ "room mention case_insensitive", "Set room mention notifications as case insensitive." },
{ "room mention word_whole", "Set room mention notifications only on whole word match, i.e. when nickname is not part of a larger word." },
{ "room mention word_part", "Set room mention notifications on partial word match, i.e. nickname may be part of a larger word." },
{ "room offline on|off", "Notifications for chat room messages that were sent while you were offline." },
{ "room current on|off", "Whether to show all chat room messages notifications when the window is focused." },
{ "room text on|off", "Show message text in chat room message notifications." },
{ "room trigger add <text>", "Notify when specified text included in all chat room messages." },
@@ -1483,6 +1485,7 @@ static struct cmd_t command_defs[] = {
"/notify chat on",
"/notify chat text on",
"/notify room mention on",
"/notify room offline on",
"/notify room trigger add beer",
"/notify room trigger on",
"/notify room current off",

View File

@@ -5775,6 +5775,16 @@ cmd_notify(ProfWin* window, const char* const command, gchar** args)
} else {
cons_show("Usage: /notify room mention on|off");
}
} else if (g_strcmp0(args[1], "offline") == 0) {
if (g_strcmp0(args[2], "on") == 0) {
cons_show("Room notifications for offline messages enabled.");
prefs_set_boolean(PREF_NOTIFY_ROOM_OFFLINE, TRUE);
} else if (g_strcmp0(args[2], "off") == 0) {
cons_show("Room notifications for offline messages disabled.");
prefs_set_boolean(PREF_NOTIFY_ROOM_OFFLINE, FALSE);
} else {
cons_show("Usage: /notify room offline on|off");
}
} else if (g_strcmp0(args[1], "current") == 0) {
if (g_strcmp0(args[2], "on") == 0) {
cons_show("Current window chat room message notifications enabled.");