summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-05-16 16:53:21 +0200
committerAttila Molnar <attilamolnar@hush.com>2015-05-16 16:53:21 +0200
commitc27122858bd8127112ad43caa3484fb2472f818f (patch)
treec07e822789b997e8b7cf8c26b59ef4c9a6b82ea0 /src
parent930fd98e48f68b050d3938607bf420844fabbc37 (diff)
cmd_names Do the HasPrivPermission() check only in the NAMES handler
Diffstat (limited to 'src')
-rw-r--r--src/coremods/core_channel/cmd_names.cpp13
-rw-r--r--src/coremods/core_channel/core_channel.h4
2 files changed, 8 insertions, 9 deletions
diff --git a/src/coremods/core_channel/cmd_names.cpp b/src/coremods/core_channel/cmd_names.cpp
index 9ae58d6fa..3af99ed2b 100644
--- a/src/coremods/core_channel/cmd_names.cpp
+++ b/src/coremods/core_channel/cmd_names.cpp
@@ -53,10 +53,11 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User
// - 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")))
+ // If the user is inside the channel or has privs, instruct SendNames() to show invisible (+i) members
+ bool show_invisible = ((c->HasUser(user)) || (user->HasPrivPermission("channels/auspex")));
+ if ((show_invisible) || (!c->IsModeSet(secretmode)))
{
- SendNames(user, c, has_user);
+ SendNames(user, c, show_invisible);
return CMD_SUCCESS;
}
}
@@ -65,10 +66,8 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User
return CMD_FAILURE;
}
-void CommandNames::SendNames(User* user, Channel* chan, bool isinside)
+void CommandNames::SendNames(User* user, Channel* chan, bool show_invisible)
{
- bool has_privs = user->HasPrivPermission("channels/auspex");
-
std::string list;
if (chan->IsModeSet(secretmode))
list.push_back('@');
@@ -87,7 +86,7 @@ void CommandNames::SendNames(User* user, Channel* chan, bool isinside)
const Channel::MemberMap& members = chan->GetUsers();
for (Channel::MemberMap::const_iterator i = members.begin(); i != members.end(); ++i)
{
- if ((!isinside) && (i->first->IsModeSet(invisiblemode)) && (!has_privs))
+ if ((!show_invisible) && (i->first->IsModeSet(invisiblemode)))
{
// Member is invisible and we are not supposed to show them
continue;
diff --git a/src/coremods/core_channel/core_channel.h b/src/coremods/core_channel/core_channel.h
index 7e213b5a5..755f876f6 100644
--- a/src/coremods/core_channel/core_channel.h
+++ b/src/coremods/core_channel/core_channel.h
@@ -104,9 +104,9 @@ class CommandNames : public Command
/** Spool the NAMES list for a given channel to the given user
* @param user User to spool the NAMES list to
* @param chan Channel whose nicklist to send
- * @param isinside If true, the user is inside the channel, if not then false
+ * @param show_invisible True to show invisible (+i) members to the user, false to omit them from the list
*/
- void SendNames(User* user, Channel* chan, bool isinside);
+ void SendNames(User* user, Channel* chan, bool show_invisible);
};
/** Handle /KICK.