1
0
mirror of https://github.com/anope/anope.git synced 2026-06-25 07:16:39 +02:00

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.
This commit is contained in:
Sadie Powell
2023-11-30 14:25:35 +00:00
parent 2d2d1972e9
commit 4e9a2df827
2 changed files with 25 additions and 7 deletions
+16
View File
@@ -755,6 +755,22 @@ privilege
xop = "HOP"
}
/*
* UNBANME privilege.
*
* Used by chanserv/unban.
*
* Users with this permission can unban themself through ChanServ.
*/
privilege
{
name = "UNBANME"
rank = 200
level = 4
flag = "U"
xop = "HOP"
}
/*
* VOICE privilege.
*
+9 -7
View File
@@ -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;