sfdfds
This commit is contained in:
parent
9cab07f3a6
commit
794ea37630
1 changed files with 4 additions and 9 deletions
|
@ -6,15 +6,10 @@ from .markdown import *
|
||||||
from .sanitize import *
|
from .sanitize import *
|
||||||
from .const import *
|
from .const import *
|
||||||
|
|
||||||
def create_comment(text, autojanny=False):
|
def create_comment(text_html, autojanny=False):
|
||||||
if autojanny: author_id = AUTOJANNY_ID
|
if autojanny: author_id = AUTOJANNY_ID
|
||||||
else: author_id = NOTIFICATIONS_ID
|
else: author_id = NOTIFICATIONS_ID
|
||||||
|
|
||||||
text_html = sanitize(Renderer2().render(mistletoe.Document(text)))
|
|
||||||
|
|
||||||
for i in re.finditer("<p>@((\w|-){1,25})", text_html):
|
|
||||||
text_html = text_html.replace(f'@{i.group(1)}', f'<a href="/@{i.group(1)}"><img loading="lazy" src="/@{i.group(1)}/pic" class="pp20">@{i.group(1)}</a>')
|
|
||||||
|
|
||||||
new_comment = Comment(author_id=author_id,
|
new_comment = Comment(author_id=author_id,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
|
@ -39,8 +34,8 @@ def send_repeatable_notification(uid, text, autojanny=False):
|
||||||
if existing_comment:
|
if existing_comment:
|
||||||
cid = existing_comment[0]
|
cid = existing_comment[0]
|
||||||
existing_notif = g.db.query(Notification.id).filter_by(user_id=uid, comment_id=cid).one_or_none()
|
existing_notif = g.db.query(Notification.id).filter_by(user_id=uid, comment_id=cid).one_or_none()
|
||||||
if existing_notif: cid = create_comment(text, autojanny)
|
if existing_notif: cid = create_comment(text_html, autojanny)
|
||||||
else: cid = create_comment(text, autojanny)
|
else: cid = create_comment(text_html, autojanny)
|
||||||
|
|
||||||
notif = Notification(comment_id=cid, user_id=uid)
|
notif = Notification(comment_id=cid, user_id=uid)
|
||||||
g.db.add(notif)
|
g.db.add(notif)
|
||||||
|
@ -65,7 +60,7 @@ def notif_comment(text, autojanny=False):
|
||||||
existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, distinguish_level=6, body_html=text_html, created_utc=0).first()
|
existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, distinguish_level=6, body_html=text_html, created_utc=0).first()
|
||||||
|
|
||||||
if existing: return existing[0]
|
if existing: return existing[0]
|
||||||
else: return create_comment(text, autojanny)
|
else: return create_comment(text_html, autojanny)
|
||||||
|
|
||||||
|
|
||||||
def add_notif(cid, uid):
|
def add_notif(cid, uid):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue