about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_ac.c2
-rw-r--r--src/command/cmd_defs.c12
-rw-r--r--src/command/cmd_funcs.c52
3 files changed, 51 insertions, 15 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 6b46d079..77cd1adc 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -951,6 +951,8 @@ cmd_ac_init(void)
     blocked_ac = autocomplete_new();
     autocomplete_add(blocked_ac, "add");
     autocomplete_add(blocked_ac, "remove");
+    autocomplete_add(blocked_ac, "report-abuse");
+    autocomplete_add(blocked_ac, "report-spam");
 
     clear_ac = autocomplete_new();
     autocomplete_add(clear_ac, "persist_history");
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index e04ba2a1..63cb8780 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -420,7 +420,7 @@ static struct cmd_t command_defs[] = {
     },
 
     { "/blocked",
-      parse_args, 0, 2, NULL,
+      parse_args_with_freetext, 0, 3, NULL,
       CMD_NOSUBFUNCS
       CMD_MAINFUNC(cmd_blocked)
       CMD_TAGS(
@@ -429,15 +429,21 @@ static struct cmd_t command_defs[] = {
       CMD_SYN(
               "/blocked",
               "/blocked add [<jid>]",
+              "/blocked report-abuse [<jid>] [<message>]",
+              "/blocked report-spam [<jid>] [<message>]",
               "/blocked remove <jid>")
       CMD_DESC(
               "Manage blocked users (XEP-0191), calling with no arguments shows the current list of blocked users. "
-              "To blog a certain user in a MUC use the following as jid: room@conference.example.org/spammy-user")
+              "To blog a certain user in a MUC use the following as jid: room@conference.example.org/spammy-user"
+              "It is also possible to block and report (XEP-0377) a user with the report-abuse and report-spam commands.")
       CMD_ARGS(
               { "add [<jid>]", "Block the specified Jabber ID. If in a chat window and no jid is specified, the current recipient will be blocked." },
-              { "remove <jid>", "Remove the specified Jabber ID from the blocked list." })
+              { "remove <jid>", "Remove the specified Jabber ID from the blocked list." },
+              { "report-abuse <jid> [<message>]", "Report the jid as abuse with an optional message to the service operator." },
+              { "report-spam <jid> [<message>]", "Report the jid as spam with an optional message to the service operator." })
       CMD_EXAMPLES(
               "/blocked add hel@helheim.edda",
+              "/blocked report-spam hel@helheim.edda Very annoying guy",
               "/blocked add profanity@rooms.dismail.de/spammy-user")
     },
 
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index e1108982..9b092939 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -3008,23 +3008,29 @@ cmd_blocked(ProfWin* window, const char* const command, gchar** args)
     }
 
     if (!connection_supports(XMPP_FEATURE_BLOCKING)) {
-        cons_show("Blocking not supported by server.");
+        cons_show("Blocking (%s) not supported by server.", XMPP_FEATURE_BLOCKING);
         return TRUE;
     }
 
+    blocked_report br = BLOCKED_NO_REPORT;
+
     if (g_strcmp0(args[0], "add") == 0) {
         char* jid = args[1];
-        if (jid == NULL && (window->type == WIN_CHAT)) {
-            ProfChatWin* chatwin = (ProfChatWin*)window;
-            jid = chatwin->barejid;
-        }
 
-        if (jid == NULL) {
-            cons_bad_cmd_usage(command);
-            return TRUE;
+        // /blocked add jid or /blocked add (in window)
+        if (g_strv_length(args) < 3) {
+            if (jid == NULL && (window->type == WIN_CHAT)) {
+                ProfChatWin* chatwin = (ProfChatWin*)window;
+                jid = chatwin->barejid;
+            }
+
+            if (jid == NULL) {
+                cons_bad_cmd_usage(command);
+                return TRUE;
+            }
         }
 
-        gboolean res = blocked_add(jid);
+        gboolean res = blocked_add(jid, br, NULL);
         if (!res) {
             cons_show("User %s already blocked.", jid);
         }
@@ -3046,6 +3052,28 @@ cmd_blocked(ProfWin* window, const char* const command, gchar** args)
         return TRUE;
     }
 
+    if (strncmp(args[0], "report-", 7) == 0) {
+        if (args[1] && g_strcmp0(args[0], "report-abuse") == 0) {
+            br = BLOCKED_REPORT_ABUSE;
+        } else if (args[1] && g_strcmp0(args[0], "report-spam") == 0) {
+            br = BLOCKED_REPORT_SPAM;
+        } else {
+            cons_bad_cmd_usage(command);
+            return TRUE;
+        }
+
+        if (!connection_supports(XMPP_FEATURE_SPAM_REPORTING)) {
+            cons_show("Spam reporting (%s) not supported by server.", XMPP_FEATURE_SPAM_REPORTING);
+            return TRUE;
+        }
+
+        // args[3] is an optional message
+        gboolean res = blocked_add(args[1], br, args[3]);
+        if (!res) {
+            cons_show("User %s already blocked.", args[1]);
+        }
+    }
+
     GList* blocked = blocked_list();
     GList* curr = blocked;
     if (curr) {
@@ -6497,7 +6525,7 @@ cmd_ping(ProfWin* window, const char* const command, gchar** args)
     }
 
     if (args[0] == NULL && connection_supports(XMPP_FEATURE_PING) == FALSE) {
-        cons_show("Server does not support ping requests.");
+        cons_show("Server does not support ping requests (%s).", XMPP_FEATURE_PING);
         return TRUE;
     }
 
@@ -8102,7 +8130,7 @@ cmd_command_list(ProfWin* window, const char* const command, gchar** args)
     }
 
     if (connection_supports(XMPP_FEATURE_COMMANDS) == FALSE) {
-        cons_show("Server does not support ad hoc commands.");
+        cons_show("Server does not support ad hoc commands (%s).", XMPP_FEATURE_COMMANDS);
         return TRUE;
     }
 
@@ -8158,7 +8186,7 @@ cmd_command_exec(ProfWin* window, const char* const command, gchar** args)
     }
 
     if (connection_supports(XMPP_FEATURE_COMMANDS) == FALSE) {
-        cons_show("Server does not support ad hoc commands.");
+        cons_show("Server does not support ad hoc commands (%s).", XMPP_FEATURE_COMMANDS);
         return TRUE;
     }
 
re>
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104