summaryrefslogtreecommitdiff
path: root/modules/commands/cs_unban.cpp
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2023-11-30 14:25:35 +0000
committerSadie Powell <sadie@witchery.services>2023-11-30 14:38:20 +0000
commit4e9a2df8274f010ff50d4a937e04cc3eff2fca72 (patch)
treee9138ecfde54eec8000a20be8a06484d7bb425dd /modules/commands/cs_unban.cpp
parent2d2d1972e965ff41b9e79a53b2bc7e739f798000 (diff)
Add the UNBANME privilege to allow users to unban themselves.
This is separate from the existing UNBAN privilege which applies to all users. Closes #331.
Diffstat (limited to 'modules/commands/cs_unban.cpp')
-rw-r--r--modules/commands/cs_unban.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/modules/commands/cs_unban.cpp b/modules/commands/cs_unban.cpp
index fec777cc0..832c1cfcb 100644
--- a/modules/commands/cs_unban.cpp
+++ b/modules/commands/cs_unban.cpp
@@ -40,7 +40,7 @@ class CommandCSUnban : public Command
unsigned count = 0;
for (auto *ci : queue)
{
- if (!ci->c || !source.AccessFor(ci).HasPriv("UNBAN"))
+ if (!ci->c || !(source.AccessFor(ci).HasPriv("UNBAN") || source.AccessFor(ci).HasPriv("UNBANME")))
continue;
FOREACH_MOD(OnChannelUnban, (source.GetUser(), ci));
@@ -69,12 +69,6 @@ class CommandCSUnban : public Command
return;
}
- if (!source.AccessFor(ci).HasPriv("UNBAN") && !source.HasPriv("chanserv/kick"))
- {
- source.Reply(ACCESS_DENIED);
- return;
- }
-
User *u2 = source.GetUser();
if (params.size() > 1)
u2 = User::Find(params[1], true);
@@ -85,6 +79,14 @@ class CommandCSUnban : public Command
return;
}
+ if (!source.AccessFor(ci).HasPriv("UNBAN") &&
+ !(u2 == source.GetUser() && source.AccessFor(ci).HasPriv("UNBANME")) &&
+ !source.HasPriv("chanserv/kick"))
+ {
+ source.Reply(ACCESS_DENIED);
+ return;
+ }
+
bool override = !source.AccessFor(ci).HasPriv("UNBAN") && source.HasPriv("chanserv/kick");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unban " << u2->nick;