notifs
This commit is contained in:
parent
0d71a2b51e
commit
afdb1b0606
3 changed files with 12 additions and 1 deletions
|
@ -66,6 +66,11 @@ class Comment(Base):
|
|||
|
||||
return f"<Comment(id={self.id})>"
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def top_comment(self):
|
||||
return g.db.query(Comment).filter_by(id=self.top_comment_id).first()
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def flags(self):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = ''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue