Skip to content

Commit 44adbc3

Browse files
authored
Adding ACL scope to reminder remove (#93)
1 parent 5cc74bd commit 44adbc3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

plugins/reminders.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from sqlalchemy.orm import Mapped, mapped_column
1212
from sqlalchemy.sql.functions import current_timestamp
1313

14-
from bot.acl import privileged
14+
from bot.acl import EvalResult, evaluate_ctx, privileged, register_action
1515
from bot.client import client
1616
from bot.commands import Context, cleanup, plugin_command
1717
from bot.tasks import task
@@ -44,6 +44,7 @@ def __init__(
4444

4545

4646
logger = logging.getLogger(__name__)
47+
manage_reminders = register_action("manage_reminders") # For use in removing reminders
4748

4849

4950
def format_msg(guild_id: int, channel_id: int, msg_id: int) -> str:
@@ -191,6 +192,10 @@ async def reminder_remove(ctx: Context, id: int) -> None:
191192
"""Delete a reminder."""
192193
async with sessionmaker() as session:
193194
if reminder := await session.get(Reminder, id):
195+
# To remove another user's reminders you need elevated permissions
196+
if reminder.user_id != ctx.author.id:
197+
if manage_reminders.evaluate(*evaluate_ctx(ctx)) != EvalResult.TRUE:
198+
raise UserError("Reminder {} is owned by a different user.".format(id))
194199
await session.delete(reminder)
195200
await session.commit()
196201
await ctx.send(

0 commit comments

Comments
 (0)