about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2021-07-01 18:21:48 +0200
committerGitHub <noreply@github.com>2021-07-01 18:21:48 +0200
commit7a4a78ab06835ee1a0cce4ec045b8774c6b59cd7 (patch)
tree420a7fd291c7121b3d628108fc33d141e2fd0f5f /src/command
parent226cffe75be5d408e1d357337eb4ed921100f3b7 (diff)
parent2386878c76dcd9099439a202fdc249e397a814b2 (diff)
downloadprofani-tty-7a4a78ab06835ee1a0cce4ec045b8774c6b59cd7.tar.gz
Merge pull request #1571 from profanity-im/feature/955-silence
Add option to only allow messages from jids in roster
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_ac.c3
-rw-r--r--src/command/cmd_defs.c14
-rw-r--r--src/command/cmd_funcs.c8
-rw-r--r--src/command/cmd_funcs.h1
4 files changed, 25 insertions, 1 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 77cd1adc..a4d61c30 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -1672,7 +1672,8 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
 
     // autocomplete boolean settings
     gchar* boolean_choices[] = { "/beep", "/states", "/outtype", "/flash", "/splash",
-                                 "/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/os", "/slashguard", "/mam" };
+                                 "/history", "/vercheck", "/privileges", "/wrap",
+                                 "/carbons", "/os", "/slashguard", "/mam", "/silence" };
 
     for (int i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
         result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice, previous, NULL);
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 63cb8780..16efea21 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -2622,6 +2622,20 @@ static struct cmd_t command_defs[] = {
       CMD_NOEXAMPLES
     },
 
+    { "/silence",
+      parse_args, 1, 1, &cons_silence_setting,
+      CMD_NOSUBFUNCS
+      CMD_MAINFUNC(cmd_silence)
+      CMD_TAGS(
+              CMD_TAG_CHAT)
+      CMD_SYN(
+              "/silence on|off")
+      CMD_DESC(
+              "Let's you silence all message attempts from people who are not in your roster.")
+      CMD_NOARGS
+      CMD_NOEXAMPLES
+    },
+
     // NEXT-COMMAND (search helper)
 };
 
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 9b092939..073abde0 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -9505,3 +9505,11 @@ cmd_editor(ProfWin* window, const char* const command, gchar** args)
     }
     return TRUE;
 }
+
+gboolean
+cmd_silence(ProfWin* window, const char* const command, gchar** args)
+{
+    _cmd_set_boolean_preference(args[0], command, "Block all messages from JIDs that are not in the roster", PREF_SILENCE_NON_ROSTER);
+
+    return TRUE;
+}
diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h
index aadcb55f..54cc6e78 100644
--- a/src/command/cmd_funcs.h
+++ b/src/command/cmd_funcs.h
@@ -246,5 +246,6 @@ gboolean cmd_executable_urlsave(ProfWin* window, const char* const command, gcha
 gboolean cmd_executable_editor(ProfWin* window, const char* const command, gchar** args);
 gboolean cmd_mam(ProfWin* window, const char* const command, gchar** args);
 gboolean cmd_editor(ProfWin* window, const char* const command, gchar** args);
+gboolean cmd_silence(ProfWin* window, const char* const command, gchar** args);
 
 #endif