summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-04-09 14:57:42 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-04-09 14:57:42 +0200
commit6dc4436ae48e6cc4b309d3cec609047920916cde (patch)
treee74afc57c53bd0fd1021c8cdb9554c0c5c717327
parentb4a7847bb8f39b466161c5fde7e58d41e81275d7 (diff)
Move checks determining whether a user is allowed to view the NAMES list of a channel from Channel::UserList() to cmd_names
-rw-r--r--src/channels.cpp6
-rw-r--r--src/coremods/core_channel/cmd_names.cpp19
2 files changed, 13 insertions, 12 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 5954d8ded..485ffd4c9 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -629,12 +629,6 @@ const char* Channel::ChanModes(bool showkey)
void Channel::UserList(User *user)
{
bool has_privs = user->HasPrivPermission("channels/auspex");
- if (this->IsModeSet(secretmode) && !this->HasUser(user) && !has_privs)
- {
- user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", this->name.c_str());
- return;
- }
-
std::string list;
list.push_back(this->IsModeSet(secretmode) ? '@' : this->IsModeSet(privatemode) ? '*' : '=');
list.push_back(' ');
diff --git a/src/coremods/core_channel/cmd_names.cpp b/src/coremods/core_channel/cmd_names.cpp
index 13d912376..558ad8407 100644
--- a/src/coremods/core_channel/cmd_names.cpp
+++ b/src/coremods/core_channel/cmd_names.cpp
@@ -46,12 +46,19 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User
c = ServerInstance->FindChan(parameters[0]);
if (c)
{
- c->UserList(user);
- }
- else
- {
- user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+ // Show the NAMES list if one of the following is true:
+ // - the channel is not secret
+ // - the user doing the /NAMES is inside the channel
+ // - the user doing the /NAMES has the channels/auspex privilege
+
+ bool has_user = c->HasUser(user);
+ if ((!c->IsModeSet(secretmode)) || (has_user) || (user->HasPrivPermission("channels/auspex")))
+ {
+ c->UserList(user);
+ return CMD_SUCCESS;
+ }
}
- return CMD_SUCCESS;
+ user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());
+ return CMD_FAILURE;
}