Add nickname support for /roster remove

Add support of name/nickname instead of only JID for `/roster remove` command.

Add tests for it as well.
This commit is contained in:
John Hernandez
2023-04-13 15:23:45 +02:00
parent 766dc76e33
commit 5b8b9074a2
9 changed files with 65 additions and 7 deletions

View File

@@ -2292,7 +2292,7 @@ _roster_autocomplete(ProfWin* window, const char* const input, gboolean previous
if (result) {
return result;
}
result = autocomplete_param_with_func(input, "/roster remove", roster_barejid_autocomplete, previous, NULL);
result = autocomplete_param_with_func(input, "/roster remove", roster_contact_autocomplete, previous, NULL);
if (result) {
return result;
}

View File

@@ -290,7 +290,7 @@ static const struct cmd_t command_defs[] = {
"/roster size <percent>",
"/roster wrap on|off",
"/roster add <jid> [<nick>]",
"/roster remove <jid>",
"/roster remove <contact>",
"/roster remove_all contacts",
"/roster nick <jid> <nick>",
"/roster clearnick <jid>",

View File

@@ -2922,14 +2922,17 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args)
cons_show("You are not currently connected.");
return TRUE;
}
char* jid = args[1];
if (jid == NULL) {
char* usr = args[1];
if (usr == NULL) {
cons_bad_cmd_usage(command);
} else {
roster_send_remove(jid);
return TRUE;
}
char* barejid = roster_barejid_from_name(usr);
if (barejid == NULL) {
barejid = usr;
}
roster_send_remove(barejid);
return TRUE;
} else if (strcmp(args[0], "remove_all") == 0) {
if (g_strcmp0(args[1], "contacts") != 0) {
cons_bad_cmd_usage(command);