This commit is contained in:
Aevann1 2021-09-24 04:21:41 +02:00
parent f45c501a8e
commit cb06fc98ec
6 changed files with 239 additions and 320 deletions

View file

@ -21,19 +21,15 @@ def send_notification(vid, user, text):
text_html = sanitize(text_html)
new_comment = Comment(author_id=vid,
parent_submission=None,
distinguish_level=6,
parent_submission=None,
distinguish_level=6,
body=text,
body_html=text_html,
)
g.db.add(new_comment)
g.db.flush()
new_aux = CommentAux(id=new_comment.id,
body=text,
body_html=text_html,
)
g.db.add(new_aux)
notif = Notification(comment_id=new_comment.id,
user_id=uid)
g.db.add(notif)
@ -45,18 +41,14 @@ def send_follow_notif(vid, user, text):
text_html = sanitize(text_html)
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
parent_submission=None,
distinguish_level=6,
parent_submission=None,
distinguish_level=6,
body=text,
body_html=text_html,
)
g.db.add(new_comment)
g.db.flush()
new_aux = CommentAux(id=new_comment.id,
body=text,
body_html=text_html,
)
g.db.add(new_aux)
notif = Notification(comment_id=new_comment.id,
user_id=user,
followsender=vid)
@ -68,18 +60,14 @@ def send_unfollow_notif(vid, user, text):
text_html = sanitize(text_html)
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
parent_submission=None,
distinguish_level=6,
parent_submission=None,
distinguish_level=6,
body=text,
body_html=text_html,
)
g.db.add(new_comment)
g.db.flush()
new_aux = CommentAux(id=new_comment.id,
body=text,
body_html=text_html,
)
g.db.add(new_aux)
notif = Notification(comment_id=new_comment.id,
user_id=user,
unfollowsender=vid)
@ -91,18 +79,14 @@ def send_block_notif(vid, user, text):
text_html = sanitize(text_html)
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
parent_submission=None,
distinguish_level=6,
parent_submission=None,
distinguish_level=6,
body=text,
body_html=text_html,
)
g.db.add(new_comment)
g.db.flush()
new_aux = CommentAux(id=new_comment.id,
body=text,
body_html=text_html,
)
g.db.add(new_aux)
notif = Notification(comment_id=new_comment.id,
user_id=user,
blocksender=vid)
@ -114,18 +98,14 @@ def send_unblock_notif(vid, user, text):
text_html = sanitize(text_html)
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
parent_submission=None,
distinguish_level=6,
parent_submission=None,
distinguish_level=6,
body=text,
body_html=text_html,
)
g.db.add(new_comment)
g.db.flush()
new_aux = CommentAux(id=new_comment.id,
body=text,
body_html=text_html,
)
g.db.add(new_aux)
notif = Notification(comment_id=new_comment.id,
user_id=user,
unblocksender=vid)
@ -144,12 +124,12 @@ def send_admin(vid, text):
new_comment = Comment(author_id=vid,
parent_submission=None,
level=1,
sentto=0
sentto=0,
body=text,
body_html=text_html,
)
g.db.add(new_comment)
g.db.flush()
new_aux = CommentAux(id=new_comment.id, body=text, body_html=text_html)
g.db.add(new_aux)
admins = g.db.query(User).options(lazyload('*')).filter(User.admin_level > 0).all()
for admin in admins: