From 35718db46f39e85de563c4b61f8fad7fe6240707 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Wed, 10 Jun 2015 19:30:44 -0400 Subject: [PATCH] fix ban command bug --- src/group_commands.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/group_commands.c b/src/group_commands.c index f44b0a4..b7f1474 100644 --- a/src/group_commands.c +++ b/src/group_commands.c @@ -169,12 +169,22 @@ void cmd_unban(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[M return; } - if (tox_group_remove_ban_entry(m, self->num, ban_id) == -1) { - line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Ban ID does not exist."); - return; - } + int ret = tox_group_remove_ban_entry(m, self->num, ban_id); - line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Ban list entry with id %d has been removed.", ban_id); + switch (ret) { + case 0: { + line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Ban list entry with id %d has been removed.", ban_id); + return; + } + case -2: { + line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "You do not have permission to unban peers."); + return; + } + default: { + line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Ban ID does not exist."); + return; + } + } } void cmd_mod(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])