summaryrefslogtreecommitdiff
path: root/src/coremods/core_mode.cpp
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2020-02-02 15:52:41 +0000
committerSadie Powell <sadie@witchery.services>2020-02-02 15:52:41 +0000
commitc2769b58d233225f8a411532d7e73a578e1ef1f0 (patch)
tree0624424e2952e0d8cea98f0bfcea52a8c7e206fe /src/coremods/core_mode.cpp
parentfd6b8bd7bde6806eb9041792e0a069f6da91b7a9 (diff)
Fix being able to see the modes of private/secret channels.
Diffstat (limited to 'src/coremods/core_mode.cpp')
-rw-r--r--src/coremods/core_mode.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/coremods/core_mode.cpp b/src/coremods/core_mode.cpp
index 8da4a2b22..99dcf8638 100644
--- a/src/coremods/core_mode.cpp
+++ b/src/coremods/core_mode.cpp
@@ -25,8 +25,11 @@
class CommandMode : public Command
{
+ private:
unsigned int sent[256];
unsigned int seq;
+ ChanModeReference secretmode;
+ ChanModeReference privatemode;
/** Show the list of one or more list modes to a user.
* @param user User to send to.
@@ -42,6 +45,18 @@ class CommandMode : public Command
*/
void DisplayCurrentModes(User* user, User* targetuser, Channel* targetchannel);
+ bool CanSeeChan(User* user, Channel* chan)
+ {
+ // A user can always see the channel modes if they are:
+ // (1) In the channel.
+ // (2) An oper with the channels/auspex privilege.
+ if (chan->HasUser(user) || user->HasPrivPermission("channels/auspex"))
+ return true;
+
+ // Otherwise, they can only see the modes when the channel is not +p or +s.
+ return !chan->IsModeSet(secretmode) && !chan->IsModeSet(privatemode);
+ }
+
public:
/** Constructor for mode.
*/
@@ -60,6 +75,8 @@ class CommandMode : public Command
CommandMode::CommandMode(Module* parent)
: Command(parent, "MODE", 1)
, seq(0)
+ , secretmode(creator, "secret")
+ , privatemode(creator, "private")
{
syntax = "<target> [[(+|-)]<modes> [<mode-parameters>]]";
memset(&sent, 0, sizeof(sent));
@@ -78,7 +95,7 @@ CmdResult CommandMode::Handle(User* user, const Params& parameters)
targetuser = ServerInstance->FindNick(target);
}
- if ((!targetchannel) && (!targetuser))
+ if ((!targetchannel || !CanSeeChan(user, targetchannel)) && (!targetuser))
{
if (target[0] == '#')
user->WriteNumeric(Numerics::NoSuchChannel(target));