remotes/1693045480750635534/spooky-22
Aevann1 2022-04-04 03:41:20 +02:00
parent 83749285c5
commit 889a8948c4
7 changed files with 21 additions and 5 deletions

View File

@ -29,7 +29,7 @@ class Comment(Base):
distinguish_level = Column(Integer, default=0)
deleted_utc = Column(Integer, default=0)
is_approved = Column(Integer, ForeignKey("users.id"))
level = Column(Integer, default=0)
level = Column(Integer, default=1)
parent_comment_id = Column(Integer, ForeignKey("comments.id"))
top_comment_id = Column(Integer)
over_18 = Column(Boolean, default=False)

View File

@ -13,6 +13,9 @@ def create_comment(text_html, autojanny=False):
distinguish_level=6)
g.db.add(new_comment)
g.db.flush()
new_comment.top_comment_id = new_comment.id
return new_comment.id
def send_repeatable_notification(uid, text, autojanny=False):

View File

@ -1007,6 +1007,9 @@ def shadowban(user_id, v):
)
g.db.add(new_comment)
g.db.flush()
new_comment.top_comment_id = new_comment.id
for admin in g.db.query(User).filter(User.admin_level > 2, User.id != v.id).all():
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
g.db.add(notif)
@ -1189,6 +1192,9 @@ def ban_user(user_id, v):
)
g.db.add(new_comment)
g.db.flush()
new_comment.top_comment_id = new_comment.id
for admin in g.db.query(User).filter(User.admin_level > 2, User.id != v.id).all():
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
g.db.add(notif)

View File

@ -108,7 +108,7 @@ def notifications(v):
Comment.deleted_utc == 0,
Comment.author_id != AUTOJANNY_ID,
Comment.body_html.notlike('<html><body><p>New rdrama mention: <a href="https://old.reddit.com/r/%')
).order_by(Comment.top_comment_id.desc()).subquery()
).order_by(Comment.top_comment_id).subquery()
comments = g.db.query(Comment).join(sq, sq.c.id == Comment.id).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
@ -121,7 +121,7 @@ def notifications(v):
Comment.deleted_utc == 0,
Comment.author_id != AUTOJANNY_ID,
Comment.body_html.notlike('<html><body><p>New rdrama mention: <a href="https://old.reddit.com/r/%')
).order_by(Comment.top_comment_id.desc()).offset(25 * (page - 1)).limit(500).all()] + [x.id for x in comments])
).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(500).all()] + [x.id for x in comments])
comms = get_comments(list(cids), v=v)

View File

@ -66,6 +66,9 @@ def request_api_keys(v):
)
g.db.add(new_comment)
g.db.flush()
new_comment.top_comment_id = new_comment.id
for admin in g.db.query(User).filter(User.admin_level > 2).all():
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
g.db.add(notif)

View File

@ -312,6 +312,8 @@ def submit_contact(v):
)
g.db.add(new_comment)
g.db.flush()
new_comment.top_comment_id = new_comment.id
for admin in g.db.query(User).filter(User.admin_level > 1).all():
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
g.db.add(notif)

View File

@ -623,12 +623,14 @@ def message2(v, username):
parent_submission=None,
level=1,
sentto=user.id,
body_html=text_html,
body_html=text_html
)
g.db.add(c)
g.db.flush()
c.top_comment_id = c.id
notif = Notification(comment_id=c.id, user_id=user.id)
g.db.add(notif)
@ -670,7 +672,7 @@ def messagereply(v):
new_comment = Comment(author_id=v.id,
parent_submission=None,
parent_comment_id=id,
top_comment_id=parent.top_comment_id if parent.top_comment_id else parent.id,
top_comment_id=parent.top_comment_id,
level=parent.level + 1,
sentto=user_id,
body_html=text_html,