This commit is contained in:
Aevann1 2021-09-23 00:27:09 +02:00
parent bfb1830b98
commit 30f42771f8
5 changed files with 26 additions and 40 deletions

View file

@ -16,7 +16,6 @@ def send_notification(vid, user, text):
uid = user.id
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))
text_html = sanitize(text_html)
@ -42,8 +41,6 @@ def send_notification(vid, user, text):
def send_follow_notif(vid, user, text):
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))
text_html = sanitize(text_html)
@ -67,8 +64,6 @@ def send_follow_notif(vid, user, text):
def send_unfollow_notif(vid, user, text):
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))
text_html = sanitize(text_html)
@ -92,8 +87,6 @@ def send_unfollow_notif(vid, user, text):
def send_block_notif(vid, user, text):
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))
text_html = sanitize(text_html)
@ -117,8 +110,6 @@ def send_block_notif(vid, user, text):
def send_unblock_notif(vid, user, text):
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))
text_html = sanitize(text_html)
@ -142,32 +133,9 @@ def send_unblock_notif(vid, user, text):
def send_pm(vid, user, text):
text_html = Renderer().render(mistletoe.Document(text))
text_html = sanitize(text_html, True)
new_comment = Comment(author_id=vid,
parent_submission=None,
level=1,
sentto=user.id
)
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.id)
g.db.add(notif)
def send_admin(vid, text):
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 = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', text)
text_html = Renderer().render(mistletoe.Document(text))