From 4238dbd4128345623b007b7e36bc77fd9b72662e Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Tue, 20 Jul 2021 00:25:55 +0100 Subject: [PATCH] Allow maintainers to delete their bot threads --- app/models/threads.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/threads.py b/app/models/threads.py index 9a816fe7..d4c6efe8 100644 --- a/app/models/threads.py +++ b/app/models/threads.py @@ -22,7 +22,6 @@ from . import db from .users import Permission, UserRank from .packages import Package - watchers = db.Table("watchers", db.Column("user_id", db.Integer, db.ForeignKey("user.id"), primary_key=True), db.Column("thread_id", db.Integer, db.ForeignKey("thread.id"), primary_key=True) @@ -85,9 +84,14 @@ class Thread(db.Model): elif perm == Permission.COMMENT_THREAD: return canSee and (not self.locked or user.rank.atLeast(UserRank.MODERATOR)) - elif perm == Permission.LOCK_THREAD or perm == Permission.DELETE_THREAD: + elif perm == Permission.LOCK_THREAD: return user.rank.atLeast(UserRank.MODERATOR) + elif perm == Permission.DELETE_THREAD: + from app.utils.models import get_system_user + return (self.author == get_system_user() and self.package and + user in self.package.maintainers) or user.rank.atLeast(UserRank.MODERATOR) + else: raise Exception("Permission {} is not related to threads".format(perm.name))