forked from MarseyWorld/MarseyWorld
master
parent
c6f3698e0f
commit
b066e685ff
|
@ -20,8 +20,7 @@ def send_notification(vid, user, text, db=None):
|
|||
|
||||
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")
|
||||
with CustomRenderer() as renderer:
|
||||
text_html = renderer.render(mistletoe.Document(text))
|
||||
text_html = CustomRenderer().render(mistletoe.Document(text))
|
||||
|
||||
text_html = sanitize(text_html)
|
||||
|
||||
|
@ -44,33 +43,11 @@ def send_notification(vid, user, text, db=None):
|
|||
db.add(notif)
|
||||
|
||||
|
||||
def send_pm(vid, user, text):
|
||||
|
||||
with CustomRenderer() as renderer: 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_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")
|
||||
|
||||
with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(text))
|
||||
text_html = CustomRenderer().render(mistletoe.Document(text))
|
||||
text_html = sanitize(text_html)
|
||||
|
||||
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
||||
|
@ -95,8 +72,7 @@ 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")
|
||||
|
||||
with CustomRenderer() as renderer:
|
||||
text_html = renderer.render(mistletoe.Document(text))
|
||||
text_html = CustomRenderer().render(mistletoe.Document(text))
|
||||
text_html = sanitize(text_html)
|
||||
|
||||
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
||||
|
@ -121,8 +97,7 @@ 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")
|
||||
|
||||
with CustomRenderer() as renderer:
|
||||
text_html = renderer.render(mistletoe.Document(text))
|
||||
text_html = CustomRenderer().render(mistletoe.Document(text))
|
||||
text_html = sanitize(text_html)
|
||||
|
||||
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
||||
|
@ -147,8 +122,7 @@ 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")
|
||||
|
||||
with CustomRenderer() as renderer:
|
||||
text_html = renderer.render(mistletoe.Document(text))
|
||||
text_html = CustomRenderer().render(mistletoe.Document(text))
|
||||
text_html = sanitize(text_html)
|
||||
|
||||
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
||||
|
@ -169,11 +143,36 @@ def send_unblock_notif(vid, user, text):
|
|||
unblocksender=vid)
|
||||
g.db.add(notif)
|
||||
|
||||
|
||||
|
||||
def send_pm(vid, user, text):
|
||||
|
||||
text_html = 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")
|
||||
|
||||
with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(text))
|
||||
text_html = mistletoe.Document(text)
|
||||
|
||||
text_html = sanitize(text_html, True)
|
||||
|
||||
|
|
|
@ -920,8 +920,7 @@ def ban_post(post_id, v):
|
|||
|
||||
ban_reason=request.form.get("reason", "")
|
||||
ban_reason = ban_reason.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")
|
||||
with CustomRenderer() as renderer:
|
||||
ban_reason = renderer.render(mistletoe.Document(ban_reason))
|
||||
ban_reason = CustomRenderer().render(mistletoe.Document(ban_reason))
|
||||
ban_reason = sanitize(ban_reason)
|
||||
|
||||
post.ban_reason = ban_reason
|
||||
|
|
|
@ -247,7 +247,7 @@ def edit_post(pid, v):
|
|||
|
||||
if body != p.body:
|
||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE): body = body.replace(i.group(1), f'![]({i.group(1)})')
|
||||
with CustomRenderer() as renderer: body_md = renderer.render(mistletoe.Document(body))
|
||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||
body_html = sanitize(body_md)
|
||||
|
||||
# Run safety filter
|
||||
|
@ -798,8 +798,7 @@ def submit_post(v):
|
|||
# render text
|
||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE): body = body.replace(i.group(1), f'![]({i.group(1)})')
|
||||
body = body.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")
|
||||
with CustomRenderer() as renderer:
|
||||
body_md = renderer.render(mistletoe.Document(body))
|
||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||
body_html = sanitize(body_md)
|
||||
|
||||
# Run safety filter
|
||||
|
|
|
@ -123,7 +123,7 @@ def settings_profile_post(v):
|
|||
# v=v,
|
||||
# error="You didn't change anything")
|
||||
|
||||
with CustomRenderer() as renderer: bio_html = renderer.render(mistletoe.Document(bio))
|
||||
bio_html = CustomRenderer().render(mistletoe.Document(bio))
|
||||
bio_html = sanitize(bio_html)
|
||||
# Run safety filter
|
||||
bans = filter_comment_html(bio_html)
|
||||
|
|
|
@ -256,7 +256,7 @@ def messagereply(v):
|
|||
if existing.parent_comment_id: return redirect(f'/notifications?messages=true#comment-{existing.parent_comment_id}')
|
||||
else: return redirect(f'/notifications?messages=true#comment-{existing.id}')
|
||||
|
||||
with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(message))
|
||||
text_html = CustomRenderer().render(mistletoe.Document(message))
|
||||
text_html = sanitize(text_html, True)
|
||||
new_comment = Comment(author_id=v.id,
|
||||
parent_submission=None,
|
||||
|
|
Loading…
Reference in New Issue