fsd
parent
79f1afa537
commit
7c2a0924ff
|
@ -12,23 +12,12 @@ import time
|
||||||
|
|
||||||
site = environ.get("DOMAIN").strip()
|
site = environ.get("DOMAIN").strip()
|
||||||
|
|
||||||
class CommentAux(Base):
|
|
||||||
|
|
||||||
__tablename__ = "comments_aux"
|
|
||||||
|
|
||||||
key_id = Column(Integer, primary_key=True)
|
|
||||||
id = Column(Integer, ForeignKey("comments.id"))
|
|
||||||
body = deferred(Column(String(10000)))
|
|
||||||
body_html = deferred(Column(String(20000)))
|
|
||||||
ban_reason = Column(String(256))
|
|
||||||
|
|
||||||
|
|
||||||
class Comment(Base):
|
class Comment(Base):
|
||||||
|
|
||||||
__tablename__ = "comments"
|
__tablename__ = "comments"
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
comment_aux = relationship("CommentAux", lazy="joined", uselist=False, innerjoin=True, primaryjoin="Comment.id==CommentAux.id")
|
|
||||||
author_id = Column(Integer, ForeignKey("users.id"))
|
author_id = Column(Integer, ForeignKey("users.id"))
|
||||||
parent_submission = Column(Integer, ForeignKey("submissions.id"))
|
parent_submission = Column(Integer, ForeignKey("submissions.id"))
|
||||||
created_utc = Column(Integer, default=0)
|
created_utc = Column(Integer, default=0)
|
||||||
|
@ -41,25 +30,23 @@ class Comment(Base):
|
||||||
is_approved = Column(Integer, default=0)
|
is_approved = Column(Integer, default=0)
|
||||||
level = Column(Integer, default=0)
|
level = Column(Integer, default=0)
|
||||||
parent_comment_id = Column(Integer, ForeignKey("comments.id"))
|
parent_comment_id = Column(Integer, ForeignKey("comments.id"))
|
||||||
|
|
||||||
over_18 = Column(Boolean, default=False)
|
over_18 = Column(Boolean, default=False)
|
||||||
is_bot = Column(Boolean, default=False)
|
is_bot = Column(Boolean, default=False)
|
||||||
is_pinned = Column(String)
|
is_pinned = Column(String)
|
||||||
sentto=Column(Integer)
|
sentto=Column(Integer)
|
||||||
|
|
||||||
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||||
oauth_app = relationship("OauthApp", viewonly=True)
|
oauth_app = relationship("OauthApp", viewonly=True)
|
||||||
|
upvotes = Column(Integer, default=1)
|
||||||
|
downvotes = Column(Integer, default=0)
|
||||||
|
body = deferred(Column(String(10000)))
|
||||||
|
body_html = deferred(Column(String(20000)))
|
||||||
|
ban_reason = Column(String(256))
|
||||||
|
|
||||||
post = relationship("Submission", viewonly=True)
|
post = relationship("Submission", viewonly=True)
|
||||||
flags = relationship("CommentFlag", lazy="dynamic", viewonly=True)
|
flags = relationship("CommentFlag", lazy="dynamic", viewonly=True)
|
||||||
author = relationship("User", primaryjoin="User.id==Comment.author_id")
|
author = relationship("User", primaryjoin="User.id==Comment.author_id")
|
||||||
|
|
||||||
upvotes = Column(Integer, default=1)
|
|
||||||
downvotes = Column(Integer, default=0)
|
|
||||||
|
|
||||||
parent_comment = relationship("Comment", remote_side=[id], viewonly=True)
|
parent_comment = relationship("Comment", remote_side=[id], viewonly=True)
|
||||||
child_comments = relationship("Comment", remote_side=[parent_comment_id], viewonly=True)
|
child_comments = relationship("Comment", remote_side=[parent_comment_id], viewonly=True)
|
||||||
|
|
||||||
awards = relationship("AwardRelationship", viewonly=True)
|
awards = relationship("AwardRelationship", viewonly=True)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -291,25 +278,6 @@ class Comment(Base):
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
|
||||||
def body(self):
|
|
||||||
if self.comment_aux: return self.comment_aux.body
|
|
||||||
else: return ""
|
|
||||||
|
|
||||||
@body.setter
|
|
||||||
def body(self, x):
|
|
||||||
self.comment_aux.body = x
|
|
||||||
g.db.add(self.comment_aux)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def body_html(self):
|
|
||||||
return self.comment_aux.body_html
|
|
||||||
|
|
||||||
@body_html.setter
|
|
||||||
def body_html(self, x):
|
|
||||||
self.comment_aux.body_html = x
|
|
||||||
g.db.add(self.comment_aux)
|
|
||||||
|
|
||||||
def realbody(self, v):
|
def realbody(self, v):
|
||||||
if self.post and self.post.club and not (v and v.paid_dues): return "<p>COUNTRY CLUB ONLY</p>"
|
if self.post and self.post.club and not (v and v.paid_dues): return "<p>COUNTRY CLUB ONLY</p>"
|
||||||
body = self.body_html
|
body = self.body_html
|
||||||
|
@ -335,15 +303,6 @@ class Comment(Base):
|
||||||
|
|
||||||
return body
|
return body
|
||||||
|
|
||||||
@property
|
|
||||||
def ban_reason(self):
|
|
||||||
return self.comment_aux.ban_reason
|
|
||||||
|
|
||||||
@ban_reason.setter
|
|
||||||
def ban_reason(self, x):
|
|
||||||
self.comment_aux.ban_reason = x
|
|
||||||
g.db.add(self.comment_aux)
|
|
||||||
|
|
||||||
@lazy
|
@lazy
|
||||||
def collapse_for_user(self, v):
|
def collapse_for_user(self, v):
|
||||||
|
|
||||||
|
|
|
@ -23,17 +23,13 @@ def send_notification(vid, user, text):
|
||||||
new_comment = Comment(author_id=vid,
|
new_comment = Comment(author_id=vid,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
|
body=text,
|
||||||
|
body_html=text_html,
|
||||||
)
|
)
|
||||||
g.db.add(new_comment)
|
g.db.add(new_comment)
|
||||||
|
|
||||||
g.db.flush()
|
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,
|
notif = Notification(comment_id=new_comment.id,
|
||||||
user_id=uid)
|
user_id=uid)
|
||||||
g.db.add(notif)
|
g.db.add(notif)
|
||||||
|
@ -47,15 +43,11 @@ def send_follow_notif(vid, user, text):
|
||||||
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
)
|
|
||||||
g.db.add(new_comment)
|
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
new_aux = CommentAux(id=new_comment.id,
|
|
||||||
body=text,
|
body=text,
|
||||||
body_html=text_html,
|
body_html=text_html,
|
||||||
)
|
)
|
||||||
g.db.add(new_aux)
|
g.db.add(new_comment)
|
||||||
|
g.db.flush()
|
||||||
|
|
||||||
notif = Notification(comment_id=new_comment.id,
|
notif = Notification(comment_id=new_comment.id,
|
||||||
user_id=user,
|
user_id=user,
|
||||||
|
@ -70,15 +62,11 @@ def send_unfollow_notif(vid, user, text):
|
||||||
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
)
|
|
||||||
g.db.add(new_comment)
|
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
new_aux = CommentAux(id=new_comment.id,
|
|
||||||
body=text,
|
body=text,
|
||||||
body_html=text_html,
|
body_html=text_html,
|
||||||
)
|
)
|
||||||
g.db.add(new_aux)
|
g.db.add(new_comment)
|
||||||
|
g.db.flush()
|
||||||
|
|
||||||
notif = Notification(comment_id=new_comment.id,
|
notif = Notification(comment_id=new_comment.id,
|
||||||
user_id=user,
|
user_id=user,
|
||||||
|
@ -93,15 +81,11 @@ def send_block_notif(vid, user, text):
|
||||||
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
)
|
|
||||||
g.db.add(new_comment)
|
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
new_aux = CommentAux(id=new_comment.id,
|
|
||||||
body=text,
|
body=text,
|
||||||
body_html=text_html,
|
body_html=text_html,
|
||||||
)
|
)
|
||||||
g.db.add(new_aux)
|
g.db.add(new_comment)
|
||||||
|
g.db.flush()
|
||||||
|
|
||||||
notif = Notification(comment_id=new_comment.id,
|
notif = Notification(comment_id=new_comment.id,
|
||||||
user_id=user,
|
user_id=user,
|
||||||
|
@ -116,15 +100,11 @@ def send_unblock_notif(vid, user, text):
|
||||||
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
)
|
|
||||||
g.db.add(new_comment)
|
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
new_aux = CommentAux(id=new_comment.id,
|
|
||||||
body=text,
|
body=text,
|
||||||
body_html=text_html,
|
body_html=text_html,
|
||||||
)
|
)
|
||||||
g.db.add(new_aux)
|
g.db.add(new_comment)
|
||||||
|
g.db.flush()
|
||||||
|
|
||||||
notif = Notification(comment_id=new_comment.id,
|
notif = Notification(comment_id=new_comment.id,
|
||||||
user_id=user,
|
user_id=user,
|
||||||
|
@ -144,12 +124,12 @@ def send_admin(vid, text):
|
||||||
new_comment = Comment(author_id=vid,
|
new_comment = Comment(author_id=vid,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
level=1,
|
level=1,
|
||||||
sentto=0
|
sentto=0,
|
||||||
|
body=text,
|
||||||
|
body_html=text_html,
|
||||||
)
|
)
|
||||||
g.db.add(new_comment)
|
g.db.add(new_comment)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
new_aux = CommentAux(id=new_comment.id, body=text, body_html=text_html)
|
|
||||||
g.db.add(new_aux)
|
|
||||||
|
|
||||||
admins = g.db.query(User).options(lazyload('*')).filter(User.admin_level > 0).all()
|
admins = g.db.query(User).options(lazyload('*')).filter(User.admin_level > 0).all()
|
||||||
for admin in admins:
|
for admin in admins:
|
||||||
|
|
|
@ -178,11 +178,11 @@ def api_comment(v):
|
||||||
return {"error": reason}, 401
|
return {"error": reason}, 401
|
||||||
|
|
||||||
# check existing
|
# check existing
|
||||||
existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id,
|
existing = g.db.query(Comment).options(lazyload('*')).filter(Comment.author_id == v.id,
|
||||||
Comment.deleted_utc == 0,
|
Comment.deleted_utc == 0,
|
||||||
Comment.parent_comment_id == parent_comment_id,
|
Comment.parent_comment_id == parent_comment_id,
|
||||||
Comment.parent_submission == parent_submission,
|
Comment.parent_submission == parent_submission,
|
||||||
CommentAux.body == body
|
Comment.body == body
|
||||||
).first()
|
).first()
|
||||||
if existing:
|
if existing:
|
||||||
return {"error": f"You already made that comment: {existing.permalink}"}, 409
|
return {"error": f"You already made that comment: {existing.permalink}"}, 409
|
||||||
|
@ -201,10 +201,9 @@ def api_comment(v):
|
||||||
similar_comments = g.db.query(Comment
|
similar_comments = g.db.query(Comment
|
||||||
).options(
|
).options(
|
||||||
lazyload('*')
|
lazyload('*')
|
||||||
).join(Comment.comment_aux
|
|
||||||
).filter(
|
).filter(
|
||||||
Comment.author_id == v.id,
|
Comment.author_id == v.id,
|
||||||
CommentAux.body.op(
|
Comment.body.op(
|
||||||
'<->')(body) < app.config["COMMENT_SPAM_SIMILAR_THRESHOLD"],
|
'<->')(body) < app.config["COMMENT_SPAM_SIMILAR_THRESHOLD"],
|
||||||
Comment.created_utc > cutoff
|
Comment.created_utc > cutoff
|
||||||
).all()
|
).all()
|
||||||
|
@ -261,17 +260,6 @@ def api_comment(v):
|
||||||
if badlink: return {"error": f"Remove the following link and try again: `{check_url}`. Reason: {badlink.reason}"}, 403
|
if badlink: return {"error": f"Remove the following link and try again: `{check_url}`. Reason: {badlink.reason}"}, 403
|
||||||
# create comment
|
# create comment
|
||||||
parent_id = parent_fullname.split("_")[1]
|
parent_id = parent_fullname.split("_")[1]
|
||||||
c = Comment(author_id=v.id,
|
|
||||||
parent_submission=parent_submission,
|
|
||||||
parent_comment_id=parent_comment_id,
|
|
||||||
level=level,
|
|
||||||
over_18=parent_post.over_18 or request.values.get("over_18","")=="true",
|
|
||||||
is_bot=is_bot,
|
|
||||||
app_id=v.client.application.id if v.client else None
|
|
||||||
)
|
|
||||||
|
|
||||||
g.db.add(c)
|
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
|
if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
|
||||||
file=request.files["file"]
|
file=request.files["file"]
|
||||||
|
@ -285,29 +273,24 @@ def api_comment(v):
|
||||||
body_html = sanitize(body_md)
|
body_html = sanitize(body_md)
|
||||||
|
|
||||||
if len(body_html) > 20000: abort(400)
|
if len(body_html) > 20000: abort(400)
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c.id,
|
c = Comment(author_id=v.id,
|
||||||
|
parent_submission=parent_submission,
|
||||||
|
parent_comment_id=parent_comment_id,
|
||||||
|
level=level,
|
||||||
|
over_18=parent_post.over_18 or request.values.get("over_18","")=="true",
|
||||||
|
is_bot=is_bot,
|
||||||
|
app_id=v.client.application.id if v.client else None,
|
||||||
body_html=body_html,
|
body_html=body_html,
|
||||||
body=body[:10000]
|
body=body[:10000]
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(c_aux)
|
g.db.add(c)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
if 'pcmemes.net' in request.host and c_aux.body.lower().startswith("based"):
|
if 'pcmemes.net' in request.host and c.body.lower().startswith("based"):
|
||||||
pill = re.match("based and (.{1,20}?)(-| )pilled", body, re.IGNORECASE)
|
pill = re.match("based and (.{1,20}?)(-| )pilled", body, re.IGNORECASE)
|
||||||
|
|
||||||
c_based = Comment(author_id=BASEDBOT_ACCOUNT,
|
|
||||||
parent_submission=parent_submission,
|
|
||||||
distinguish_level=6,
|
|
||||||
parent_comment_id=c.id,
|
|
||||||
level=level+1,
|
|
||||||
is_bot=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
g.db.add(c_based)
|
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
if level == 1: basedguy = get_account(c.post.author_id)
|
if level == 1: basedguy = get_account(c.post.author_id)
|
||||||
else: basedguy = get_account(c.parent_comment.author_id)
|
else: basedguy = get_account(c.parent_comment.author_id)
|
||||||
basedguy.basedcount += 1
|
basedguy.basedcount += 1
|
||||||
|
@ -319,57 +302,38 @@ def api_comment(v):
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body2))
|
body_md = CustomRenderer().render(mistletoe.Document(body2))
|
||||||
|
|
||||||
body_based_html = sanitize(body_md)
|
body_based_html = sanitize(body_md)
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c_based.id,
|
c_based = Comment(author_id=BASEDBOT_ACCOUNT,
|
||||||
|
parent_submission=parent_submission,
|
||||||
|
distinguish_level=6,
|
||||||
|
parent_comment_id=c.id,
|
||||||
|
level=level+1,
|
||||||
|
is_bot=True,
|
||||||
body_html=body_based_html,
|
body_html=body_based_html,
|
||||||
body=body2
|
body=body2
|
||||||
)
|
)
|
||||||
g.db.add(c_aux)
|
|
||||||
|
g.db.add(c_based)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
n = Notification(comment_id=c_based.id, user_id=v.id)
|
n = Notification(comment_id=c_based.id, user_id=v.id)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
|
||||||
|
|
||||||
if "rdrama" in request.host and "ivermectin" in c_aux.body.lower():
|
if "rdrama" in request.host and "ivermectin" in c.body.lower():
|
||||||
|
|
||||||
c.is_banned = True
|
c.is_banned = True
|
||||||
c.ban_reason = "ToS Violation"
|
c.ban_reason = "ToS Violation"
|
||||||
|
|
||||||
g.db.add(c)
|
g.db.add(c)
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
|
||||||
parent_submission=parent_submission,
|
|
||||||
distinguish_level=6,
|
|
||||||
parent_comment_id=c.id,
|
|
||||||
level=level+1,
|
|
||||||
is_bot=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
g.db.add(c_jannied)
|
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
body2 = VAXX_MSG.format(username=v.username)
|
body2 = VAXX_MSG.format(username=v.username)
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body2))
|
body_md = CustomRenderer().render(mistletoe.Document(body2))
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c_jannied.id,
|
|
||||||
body_html=body_jannied_html,
|
|
||||||
body=body2
|
|
||||||
)
|
|
||||||
g.db.add(c_aux)
|
|
||||||
g.db.flush()
|
|
||||||
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
|
||||||
g.db.add(n)
|
|
||||||
|
|
||||||
if v.agendaposter and "trans lives matter" not in c_aux.body_html.lower():
|
|
||||||
|
|
||||||
c.is_banned = True
|
|
||||||
c.ban_reason = "ToS Violation"
|
|
||||||
|
|
||||||
g.db.add(c)
|
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_submission,
|
||||||
|
@ -377,23 +341,50 @@ def api_comment(v):
|
||||||
parent_comment_id=c.id,
|
parent_comment_id=c.id,
|
||||||
level=level+1,
|
level=level+1,
|
||||||
is_bot=True,
|
is_bot=True,
|
||||||
|
body_html=body_jannied_html,
|
||||||
|
body=body2
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(c_jannied)
|
g.db.add(c_jannied)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
||||||
|
g.db.add(n)
|
||||||
|
|
||||||
|
if v.agendaposter and "trans lives matter" not in c.body_html.lower():
|
||||||
|
|
||||||
|
c.is_banned = True
|
||||||
|
c.ban_reason = "ToS Violation"
|
||||||
|
|
||||||
|
g.db.add(c)
|
||||||
|
|
||||||
|
|
||||||
body = AGENDAPOSTER_MSG.format(username=v.username)
|
body = AGENDAPOSTER_MSG.format(username=v.username)
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c_jannied.id,
|
|
||||||
|
|
||||||
|
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
||||||
|
parent_submission=parent_submission,
|
||||||
|
distinguish_level=6,
|
||||||
|
parent_comment_id=c.id,
|
||||||
|
level=level+1,
|
||||||
|
is_bot=True,
|
||||||
body_html=body_jannied_html,
|
body_html=body_jannied_html,
|
||||||
body=body
|
body=body
|
||||||
)
|
)
|
||||||
g.db.add(c_aux)
|
|
||||||
|
g.db.add(c_jannied)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
|
||||||
|
@ -407,27 +398,28 @@ def api_comment(v):
|
||||||
g.db.add(c)
|
g.db.add(c)
|
||||||
|
|
||||||
if "rdrama" in request.host and len(body) >= 1000 and v.username != "Snappy" and "</blockquote>" not in body_html:
|
if "rdrama" in request.host and len(body) >= 1000 and v.username != "Snappy" and "</blockquote>" not in body_html:
|
||||||
c2 = Comment(author_id=LONGPOSTBOT_ACCOUNT,
|
|
||||||
parent_submission=parent_submission,
|
|
||||||
parent_comment_id=c.id,
|
|
||||||
level=level+1,
|
|
||||||
is_bot=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
g.db.add(c2)
|
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
body = random.choice(LONGPOST_REPLIES)
|
body = random.choice(LONGPOST_REPLIES)
|
||||||
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
|
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
body_html2 = sanitize(body_md)
|
body_html2 = sanitize(body_md)
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c2.id,
|
|
||||||
|
|
||||||
|
c2 = Comment(author_id=LONGPOSTBOT_ACCOUNT,
|
||||||
|
parent_submission=parent_submission,
|
||||||
|
parent_comment_id=c.id,
|
||||||
|
level=level+1,
|
||||||
|
is_bot=True,
|
||||||
body_html=body_html2,
|
body_html=body_html2,
|
||||||
body=body
|
body=body
|
||||||
)
|
)
|
||||||
g.db.add(c_aux)
|
|
||||||
|
g.db.add(c2)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
n = Notification(comment_id=c2.id, user_id=v.id)
|
n = Notification(comment_id=c2.id, user_id=v.id)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
|
||||||
|
@ -438,56 +430,62 @@ def api_comment(v):
|
||||||
|
|
||||||
|
|
||||||
if "rdrama" in request.host and random.random() < 0.001 and v.username != "Snappy" and v.username != "zozbot":
|
if "rdrama" in request.host and random.random() < 0.001 and v.username != "Snappy" and v.username != "zozbot":
|
||||||
|
|
||||||
|
body = "zoz"
|
||||||
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
|
body_html2 = sanitize(body_md)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
c2 = Comment(author_id=1833,
|
c2 = Comment(author_id=1833,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_submission,
|
||||||
parent_comment_id=c.id,
|
parent_comment_id=c.id,
|
||||||
level=level+1,
|
level=level+1,
|
||||||
is_bot=True,
|
is_bot=True,
|
||||||
|
body_html=body_html2,
|
||||||
|
body=body
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(c2)
|
g.db.add(c2)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
body = "zoz"
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
|
||||||
body_html2 = sanitize(body_md)
|
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c2.id,
|
|
||||||
body_html=body_html2,
|
|
||||||
body=body
|
|
||||||
)
|
|
||||||
g.db.add(c_aux)
|
|
||||||
g.db.flush()
|
|
||||||
n = Notification(comment_id=c2.id, user_id=v.id)
|
n = Notification(comment_id=c2.id, user_id=v.id)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
body = "zle"
|
||||||
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
|
body_html2 = sanitize(body_md)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
c3 = Comment(author_id=1833,
|
c3 = Comment(author_id=1833,
|
||||||
parent_submission=parent_submission,
|
parent_submission=parent_submission,
|
||||||
parent_comment_id=c2.id,
|
parent_comment_id=c2.id,
|
||||||
level=level+2,
|
level=level+2,
|
||||||
is_bot=True,
|
is_bot=True,
|
||||||
|
body_html=body_html2,
|
||||||
|
body=body,
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(c3)
|
g.db.add(c3)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
body = "zle"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
body = "zozzle"
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
body_html2 = sanitize(body_md)
|
body_html2 = sanitize(body_md)
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c3.id,
|
|
||||||
body_html=body_html2,
|
|
||||||
body=body
|
|
||||||
)
|
|
||||||
g.db.add(c_aux)
|
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
c4 = Comment(author_id=1833,
|
c4 = Comment(author_id=1833,
|
||||||
|
@ -495,24 +493,13 @@ def api_comment(v):
|
||||||
parent_comment_id=c3.id,
|
parent_comment_id=c3.id,
|
||||||
level=level+3,
|
level=level+3,
|
||||||
is_bot=True,
|
is_bot=True,
|
||||||
|
body_html=body_html2,
|
||||||
|
body=body
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(c4)
|
g.db.add(c4)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
body = "zozzle"
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
|
||||||
body_html2 = sanitize(body_md)
|
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c4.id,
|
|
||||||
body_html=body_html2,
|
|
||||||
body=body
|
|
||||||
)
|
|
||||||
g.db.add(c_aux)
|
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -665,10 +652,9 @@ def edit_comment(cid, v):
|
||||||
similar_comments = g.db.query(Comment
|
similar_comments = g.db.query(Comment
|
||||||
).options(
|
).options(
|
||||||
lazyload('*')
|
lazyload('*')
|
||||||
).join(Comment.comment_aux
|
|
||||||
).filter(
|
).filter(
|
||||||
Comment.author_id == v.id,
|
Comment.author_id == v.id,
|
||||||
CommentAux.body.op(
|
Comment.body.op(
|
||||||
'<->')(body) < app.config["SPAM_SIMILARITY_THRESHOLD"],
|
'<->')(body) < app.config["SPAM_SIMILARITY_THRESHOLD"],
|
||||||
Comment.created_utc > cutoff
|
Comment.created_utc > cutoff
|
||||||
).all()
|
).all()
|
||||||
|
@ -717,29 +703,29 @@ def edit_comment(cid, v):
|
||||||
|
|
||||||
g.db.add(c)
|
g.db.add(c)
|
||||||
|
|
||||||
|
body = VAXX_MSG.format(username=v.username)
|
||||||
|
|
||||||
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
|
|
||||||
|
body_jannied_html = sanitize(body_md)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
||||||
parent_submission=c.parent_submission,
|
parent_submission=c.parent_submission,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
parent_comment_id=c.id,
|
parent_comment_id=c.id,
|
||||||
level=c.level+1,
|
level=c.level+1,
|
||||||
is_bot=True,
|
is_bot=True,
|
||||||
|
body_html=body_jannied_html,
|
||||||
|
body=body
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(c_jannied)
|
g.db.add(c_jannied)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
body = VAXX_MSG.format(username=v.username)
|
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c_jannied.id,
|
|
||||||
body_html=body_jannied_html,
|
|
||||||
body=body
|
|
||||||
)
|
|
||||||
g.db.add(c_aux)
|
|
||||||
g.db.flush()
|
|
||||||
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
|
||||||
|
@ -751,29 +737,30 @@ def edit_comment(cid, v):
|
||||||
|
|
||||||
g.db.add(c)
|
g.db.add(c)
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
|
||||||
parent_submission=c.parent_submission,
|
|
||||||
distinguish_level=6,
|
|
||||||
parent_comment_id=c.id,
|
|
||||||
level=c.level+1,
|
|
||||||
is_bot=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
g.db.add(c_jannied)
|
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
body = AGENDAPOSTER_MSG.format(username=v.username)
|
body = AGENDAPOSTER_MSG.format(username=v.username)
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c_jannied.id,
|
|
||||||
|
|
||||||
|
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
||||||
|
parent_submission=c.parent_submission,
|
||||||
|
distinguish_level=6,
|
||||||
|
parent_comment_id=c.id,
|
||||||
|
level=c.level+1,
|
||||||
|
is_bot=True,
|
||||||
body_html=body_jannied_html,
|
body_html=body_jannied_html,
|
||||||
body=body
|
body=body,
|
||||||
)
|
)
|
||||||
g.db.add(c_aux)
|
|
||||||
|
g.db.add(c_jannied)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
|
||||||
|
|
|
@ -287,6 +287,13 @@ def edit_post(pid, v):
|
||||||
|
|
||||||
g.db.add(p)
|
g.db.add(p)
|
||||||
|
|
||||||
|
body = VAXX_MSG.format(username=v.username)
|
||||||
|
|
||||||
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
|
|
||||||
|
body_jannied_html = sanitize(body_md)
|
||||||
|
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
||||||
parent_submission=p.id,
|
parent_submission=p.id,
|
||||||
level=1,
|
level=1,
|
||||||
|
@ -294,24 +301,15 @@ def edit_post(pid, v):
|
||||||
is_bot=True,
|
is_bot=True,
|
||||||
app_id=None,
|
app_id=None,
|
||||||
is_pinned=True,
|
is_pinned=True,
|
||||||
distinguish_level=6
|
distinguish_level=6,
|
||||||
|
body_html=body_jannied_html,
|
||||||
|
body=body
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(c_jannied)
|
g.db.add(c_jannied)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
body = VAXX_MSG.format(username=v.username)
|
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c_jannied.id,
|
|
||||||
body_html=body_jannied_html,
|
|
||||||
body=body
|
|
||||||
)
|
|
||||||
g.db.add(c_aux)
|
|
||||||
g.db.flush()
|
|
||||||
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
|
||||||
|
@ -323,6 +321,12 @@ def edit_post(pid, v):
|
||||||
|
|
||||||
g.db.add(p)
|
g.db.add(p)
|
||||||
|
|
||||||
|
body = AGENDAPOSTER_MSG.format(username=v.username)
|
||||||
|
|
||||||
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
|
|
||||||
|
body_jannied_html = sanitize(body_md)
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
||||||
parent_submission=p.id,
|
parent_submission=p.id,
|
||||||
level=1,
|
level=1,
|
||||||
|
@ -330,24 +334,14 @@ def edit_post(pid, v):
|
||||||
is_bot=True,
|
is_bot=True,
|
||||||
app_id=None,
|
app_id=None,
|
||||||
is_pinned=True,
|
is_pinned=True,
|
||||||
distinguish_level=6
|
distinguish_level=6,
|
||||||
|
body_html=body_jannied_html,
|
||||||
|
body=body
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(c_jannied)
|
g.db.add(c_jannied)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
body = AGENDAPOSTER_MSG.format(username=v.username)
|
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c_jannied.id,
|
|
||||||
body_html=body_jannied_html,
|
|
||||||
body=body
|
|
||||||
)
|
|
||||||
g.db.add(c_aux)
|
|
||||||
g.db.flush()
|
|
||||||
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
|
||||||
|
@ -941,49 +935,21 @@ def submit_post(v):
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
|
||||||
if "rdrama" in request.host and "ivermectin" in new_post_aux.body_html.lower():
|
if "rdrama" in request.host and "ivermectin" in new_post.body_html.lower():
|
||||||
|
|
||||||
new_post.is_banned = True
|
new_post.is_banned = True
|
||||||
new_post.ban_reason = "ToS Violation"
|
new_post.ban_reason = "ToS Violation"
|
||||||
|
|
||||||
g.db.add(new_post)
|
g.db.add(new_post)
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
|
||||||
parent_submission=new_post.id,
|
|
||||||
level=1,
|
|
||||||
over_18=False,
|
|
||||||
is_bot=True,
|
|
||||||
app_id=None,
|
|
||||||
is_pinned=True,
|
|
||||||
distinguish_level=6
|
|
||||||
)
|
|
||||||
|
|
||||||
g.db.add(c_jannied)
|
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
body = VAXX_MSG.format(username=v.username)
|
body = VAXX_MSG.format(username=v.username)
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c_jannied.id,
|
|
||||||
body_html=body_jannied_html,
|
|
||||||
body=body
|
|
||||||
)
|
|
||||||
g.db.add(c_aux)
|
|
||||||
g.db.flush()
|
|
||||||
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
|
||||||
g.db.add(n)
|
|
||||||
|
|
||||||
|
|
||||||
if v.agendaposter and "trans lives matter" not in new_post_aux.body_html.lower():
|
|
||||||
|
|
||||||
new_post.is_banned = True
|
|
||||||
new_post.ban_reason = "ToS Violation"
|
|
||||||
|
|
||||||
g.db.add(new_post)
|
|
||||||
|
|
||||||
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
||||||
parent_submission=new_post.id,
|
parent_submission=new_post.id,
|
||||||
level=1,
|
level=1,
|
||||||
|
@ -991,40 +957,55 @@ def submit_post(v):
|
||||||
is_bot=True,
|
is_bot=True,
|
||||||
app_id=None,
|
app_id=None,
|
||||||
is_pinned=True,
|
is_pinned=True,
|
||||||
distinguish_level=6
|
distinguish_level=6,
|
||||||
|
body_html=body_jannied_html,
|
||||||
|
body=body,
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(c_jannied)
|
g.db.add(c_jannied)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
|
||||||
|
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
||||||
|
g.db.add(n)
|
||||||
|
|
||||||
|
|
||||||
|
if v.agendaposter and "trans lives matter" not in new_post.body_html.lower():
|
||||||
|
|
||||||
|
new_post.is_banned = True
|
||||||
|
new_post.ban_reason = "ToS Violation"
|
||||||
|
|
||||||
|
g.db.add(new_post)
|
||||||
|
|
||||||
body = AGENDAPOSTER_MSG.format(username=v.username)
|
body = AGENDAPOSTER_MSG.format(username=v.username)
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c_jannied.id,
|
|
||||||
body_html=body_jannied_html,
|
|
||||||
body=body
|
|
||||||
)
|
|
||||||
g.db.add(c_aux)
|
|
||||||
g.db.flush()
|
|
||||||
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
|
||||||
g.db.add(n)
|
|
||||||
|
|
||||||
if "rdrama" in request.host or (new_post.url and not "weebzone" in request.host and not "marsey.tech" in request.host):
|
|
||||||
c = Comment(author_id=261,
|
|
||||||
distinguish_level=6,
|
c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT,
|
||||||
parent_submission=new_post.id,
|
parent_submission=new_post.id,
|
||||||
level=1,
|
level=1,
|
||||||
over_18=False,
|
over_18=False,
|
||||||
is_bot=True,
|
is_bot=True,
|
||||||
app_id=None,
|
app_id=None,
|
||||||
|
is_pinned=True,
|
||||||
|
distinguish_level=6,
|
||||||
|
body_html=body_jannied_html,
|
||||||
|
body=body,
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(c)
|
g.db.add(c_jannied)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
n = Notification(comment_id=c_jannied.id, user_id=v.id)
|
||||||
|
g.db.add(n)
|
||||||
|
|
||||||
|
if "rdrama" in request.host or (new_post.url and not "weebzone" in request.host and not "marsey.tech" in request.host):
|
||||||
new_post.comment_count = 1
|
new_post.comment_count = 1
|
||||||
g.db.add(new_post)
|
g.db.add(new_post)
|
||||||
|
|
||||||
|
@ -1043,13 +1024,24 @@ def submit_post(v):
|
||||||
gevent.spawn(archiveorg, new_post.url)
|
gevent.spawn(archiveorg, new_post.url)
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
body_html = sanitize(body_md)
|
body_html = sanitize(body_md)
|
||||||
c_aux = CommentAux(
|
|
||||||
id=c.id,
|
|
||||||
|
c = Comment(author_id=261,
|
||||||
|
distinguish_level=6,
|
||||||
|
parent_submission=new_post.id,
|
||||||
|
level=1,
|
||||||
|
over_18=False,
|
||||||
|
is_bot=True,
|
||||||
|
app_id=None,
|
||||||
body_html=body_html,
|
body_html=body_html,
|
||||||
body=body
|
body=body,
|
||||||
)
|
)
|
||||||
g.db.add(c_aux)
|
|
||||||
|
g.db.add(c)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
n = Notification(comment_id=c.id, user_id=v.id)
|
n = Notification(comment_id=c.id, user_id=v.id)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
|
@ -208,11 +208,11 @@ def searchcomments(v):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
comments = g.db.query(Comment.id).options(lazyload('*')).filter(Comment.parent_submission != None).join(Comment.comment_aux)
|
comments = g.db.query(Comment.id).options(lazyload('*')).filter(Comment.parent_submission != None)
|
||||||
|
|
||||||
if 'q' in criteria:
|
if 'q' in criteria:
|
||||||
words=criteria['q'].split()
|
words=criteria['q'].split()
|
||||||
words=[CommentAux.body.ilike('%'+x+'%') for x in words]
|
words=[Comment.body.ilike('%'+x+'%') for x in words]
|
||||||
words=tuple(words)
|
words=tuple(words)
|
||||||
comments=comments.filter(*words)
|
comments=comments.filter(*words)
|
||||||
|
|
||||||
|
|
|
@ -224,9 +224,9 @@ def message2(v, username):
|
||||||
message = request.values.get("message", "")[:1000].strip()
|
message = request.values.get("message", "")[:1000].strip()
|
||||||
|
|
||||||
# check existing
|
# check existing
|
||||||
existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id,
|
existing = g.db.query(Comment).options(lazyload('*')).filter(Comment.author_id == v.id,
|
||||||
Comment.sentto == user.id,
|
Comment.sentto == user.id,
|
||||||
CommentAux.body == message,
|
Comment.body == message,
|
||||||
).first()
|
).first()
|
||||||
if existing: return redirect('/notifications?messages=true')
|
if existing: return redirect('/notifications?messages=true')
|
||||||
|
|
||||||
|
@ -239,14 +239,14 @@ def message2(v, username):
|
||||||
new_comment = Comment(author_id=v.id,
|
new_comment = Comment(author_id=v.id,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
level=1,
|
level=1,
|
||||||
sentto=user.id
|
sentto=user.id,
|
||||||
|
body=text,
|
||||||
|
body_html=text_html,
|
||||||
)
|
)
|
||||||
g.db.add(new_comment)
|
g.db.add(new_comment)
|
||||||
|
|
||||||
g.db.flush()
|
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)
|
notif = Notification(comment_id=new_comment.id, user_id=user.id)
|
||||||
g.db.add(notif)
|
g.db.add(notif)
|
||||||
|
@ -284,9 +284,9 @@ def messagereply(v):
|
||||||
message = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', message)
|
message = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', message)
|
||||||
|
|
||||||
# check existing
|
# check existing
|
||||||
existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id,
|
existing = g.db.query(Comment).options(lazyload('*')).filter(Comment.author_id == v.id,
|
||||||
Comment.sentto == user.id,
|
Comment.sentto == user.id,
|
||||||
CommentAux.body == message,
|
Comment.body == message,
|
||||||
).first()
|
).first()
|
||||||
if existing:
|
if existing:
|
||||||
if existing.parent_comment_id: return redirect(f'/notifications?messages=true#comment-{existing.parent_comment_id}')
|
if existing.parent_comment_id: return redirect(f'/notifications?messages=true#comment-{existing.parent_comment_id}')
|
||||||
|
@ -298,12 +298,13 @@ def messagereply(v):
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
parent_comment_id=id,
|
parent_comment_id=id,
|
||||||
level=parent.level + 1,
|
level=parent.level + 1,
|
||||||
sentto=user.id
|
sentto=user.id,
|
||||||
|
body=message,
|
||||||
|
body_html=text_html,
|
||||||
)
|
)
|
||||||
g.db.add(new_comment)
|
g.db.add(new_comment)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
new_aux = CommentAux(id=new_comment.id, body=message, body_html=text_html)
|
|
||||||
g.db.add(new_aux)
|
|
||||||
notif = Notification(comment_id=new_comment.id, user_id=user.id)
|
notif = Notification(comment_id=new_comment.id, user_id=user.id)
|
||||||
g.db.add(notif)
|
g.db.add(notif)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue