1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-23 21:45:30 +00:00

Reorder /blocked commands

Instead of `/blocked add [<jid>] [report-abuse|report-spam [<message>]`
have:
* /blocked add [<jid>] [<message>] (like before)
* /blocked report-abuse [<jid>] [<message>]
* /blocked report-spam [<jid>] [<message>]
This commit is contained in:
Michael Vetter 2021-07-01 10:53:11 +02:00
parent 2f533c5da4
commit 1d845c9ffb
3 changed files with 37 additions and 26 deletions

View File

@ -951,6 +951,8 @@ cmd_ac_init(void)
blocked_ac = autocomplete_new(); blocked_ac = autocomplete_new();
autocomplete_add(blocked_ac, "add"); autocomplete_add(blocked_ac, "add");
autocomplete_add(blocked_ac, "remove"); autocomplete_add(blocked_ac, "remove");
autocomplete_add(blocked_ac, "report-abuse");
autocomplete_add(blocked_ac, "report-spam");
clear_ac = autocomplete_new(); clear_ac = autocomplete_new();
autocomplete_add(clear_ac, "persist_history"); autocomplete_add(clear_ac, "persist_history");

View File

@ -420,7 +420,7 @@ static struct cmd_t command_defs[] = {
}, },
{ "/blocked", { "/blocked",
parse_args_with_freetext, 0, 4, NULL, parse_args_with_freetext, 0, 3, NULL,
CMD_NOSUBFUNCS CMD_NOSUBFUNCS
CMD_MAINFUNC(cmd_blocked) CMD_MAINFUNC(cmd_blocked)
CMD_TAGS( CMD_TAGS(
@ -428,17 +428,22 @@ static struct cmd_t command_defs[] = {
CMD_TAG_CHAT) CMD_TAG_CHAT)
CMD_SYN( CMD_SYN(
"/blocked", "/blocked",
"/blocked add [<jid>] [report-abuse|report-spam [<message>]", "/blocked add [<jid>]",
"/blocked report-abuse [<jid>] [<message>]",
"/blocked report-spam [<jid>] [<message>]",
"/blocked remove <jid>") "/blocked remove <jid>")
CMD_DESC( CMD_DESC(
"Manage blocked users (XEP-0191), calling with no arguments shows the current list of blocked users. " "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( 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." }, { "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( CMD_EXAMPLES(
"/blocked add hel@helheim.edda", "/blocked add hel@helheim.edda",
"/blocked add hel@helheim.edda report-spam", "/blocked report-spam hel@helheim.edda Very annoying guy",
"/blocked add profanity@rooms.dismail.de/spammy-user") "/blocked add profanity@rooms.dismail.de/spammy-user")
}, },

View File

@ -3012,10 +3012,10 @@ cmd_blocked(ProfWin* window, const char* const command, gchar** args)
return TRUE; return TRUE;
} }
blocked_report br = BLOCKED_NO_REPORT;
if (g_strcmp0(args[0], "add") == 0) { if (g_strcmp0(args[0], "add") == 0) {
char* jid = args[1]; char* jid = args[1];
char* msg = NULL;
blocked_report br = BLOCKED_NO_REPORT;
// /blocked add jid or /blocked add (in window) // /blocked add jid or /blocked add (in window)
if (g_strv_length(args) < 3) { if (g_strv_length(args) < 3) {
@ -3028,27 +3028,9 @@ cmd_blocked(ProfWin* window, const char* const command, gchar** args)
cons_bad_cmd_usage(command); cons_bad_cmd_usage(command);
return TRUE; return TRUE;
} }
} else {
if (args[2] && g_strcmp0(args[2], "report-abuse") == 0) {
br = BLOCKED_REPORT_ABUSE;
} else if (args[2] && g_strcmp0(args[2], "report-abuse") == 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;
}
msg = args[3];
} }
// args[3] is optional message gboolean res = blocked_add(jid, br, NULL);
gboolean res = blocked_add(jid, br, msg);
if (!res) { if (!res) {
cons_show("User %s already blocked.", jid); cons_show("User %s already blocked.", jid);
} }
@ -3070,6 +3052,28 @@ cmd_blocked(ProfWin* window, const char* const command, gchar** args)
return TRUE; 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* blocked = blocked_list();
GList* curr = blocked; GList* curr = blocked;
if (curr) { if (curr) {