df
This commit is contained in:
parent
fdeb1e997b
commit
06669e9d4e
8 changed files with 32 additions and 40 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue