diff --git a/files/classes/comment.py b/files/classes/comment.py index 069a6ed918..34f1332db2 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -66,6 +66,11 @@ class Comment(Base): return f"" + @property + @lazy + def top_comment(self): + return g.db.query(Comment).filter_by(id=self.top_comment_id).first() + @property @lazy def flags(self): diff --git a/files/routes/comments.py b/files/routes/comments.py index 84032235f4..a35ba56e70 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -51,7 +51,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): if comment.post and comment.post.club and not (v and (v.paid_dues or v.id in [comment.author_id, comment.post.author_id])): abort(403) - if not comment.parent_submission and not (v and (comment.author.id == v.id or comment.sentto == v.id)) and not (v and v.admin_level > 1) : abort(403) + if not comment.parent_submission: abort(403) if not pid: if comment.parent_submission: pid = comment.parent_submission diff --git a/files/routes/users.py b/files/routes/users.py index 56ed9c213f..fd801b7d8f 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -478,6 +478,7 @@ def messagereply(v): new_comment = Comment(author_id=v.id, parent_submission=None, parent_comment_id=id, + top_comment_id=parent.top_comment_id if parent.top_comment_id else parent.id, level=parent.level + 1, sentto=user_id, body_html=text_html, @@ -488,6 +489,11 @@ def messagereply(v): notif = Notification(comment_id=new_comment.id, user_id=user_id) g.db.add(notif) + if new_comment.top_comment.sentto == 0: + admins = g.db.query(User).filter(User.admin_level > 2, User.id != v.id, User.id != user_id).all() + for admin in admins: + notif = Notification(comment_id=new_comment.id, user_id=admin.id) + g.db.add(notif) g.db.commit() if not v or v.oldsite: template = ''