This commit is contained in:
Aevann1 2021-09-17 10:55:55 +02:00
parent fdeb1e997b
commit 06669e9d4e
8 changed files with 32 additions and 40 deletions

View file

@ -7,7 +7,7 @@ from .sanitize import *
from .const import *
def send_notification(vid, user, text, db=None):
def send_notification(vid, user, text):
# for when working outside request context
if isinstance(user, int):
@ -15,9 +15,6 @@ def send_notification(vid, user, text, db=None):
else:
uid = user.id
if not db:
db = g.db
text = text.replace('r/', 'r\/').replace('u/', 'u\/')
text = text.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
text_html = CustomRenderer().render(mistletoe.Document(text))
@ -28,20 +25,20 @@ def send_notification(vid, user, text, db=None):
parent_submission=None,
distinguish_level=6,
)
db.add(new_comment)
g.db.add(new_comment)
db.flush()
g.db.flush()
new_aux = CommentAux(id=new_comment.id,
body=text,
body_html=text_html,
)
db.add(new_aux)
g.db.add(new_aux)
notif = Notification(comment_id=new_comment.id,
user_id=uid)
db.add(notif)
db.commit()
g.db.add(notif)
g.db.commit()
def send_follow_notif(vid, user, text):