remotes/1693045480750635534/spooky-22
Aevann1 2022-01-31 05:28:20 +02:00
parent 3f8c9ab930
commit 46e52b4fc6
1 changed files with 22 additions and 15 deletions

View File

@ -51,7 +51,7 @@ def notifications(v):
elif posts: elif posts:
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ID).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(101).all() notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ID).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(101).all()
listing = [] listing = set()
for index, x in enumerate(notifications[:100]): for index, x in enumerate(notifications[:100]):
c = x.comment c = x.comment
@ -60,7 +60,7 @@ def notifications(v):
x.read = True x.read = True
c.unread = True c.unread = True
g.db.add(x) g.db.add(x)
listing.append(c) listing.add(c)
g.db.commit() g.db.commit()
@ -89,16 +89,18 @@ def notifications(v):
g.db.commit() g.db.commit()
if not posts: if not posts:
listing = [] listing = set()
all = set()
for c in comments: for c in comments:
c.is_blocked = False c.is_blocked = False
c.is_blocking = False c.is_blocking = False
if c.parent_submission and c.parent_comment and c.parent_comment.author_id == v.id: if c.parent_submission and c.parent_comment and c.parent_comment.author_id == v.id:
replies = [] replies = set()
for x in c.replies: for x in c.replies:
if x.author_id == v.id: if x.id not in all and x.author_id == v.id:
x.voted = 1 x.voted = 1
replies.append(x) replies.add(x)
all.add(x.id)
c.replies = replies c.replies = replies
while c.parent_comment and c.parent_comment.author_id == v.id: while c.parent_comment and c.parent_comment.author_id == v.id:
parent = c.parent_comment parent = c.parent_comment
@ -106,25 +108,30 @@ def notifications(v):
parent.replies2 = parent.replies2 + [c] parent.replies2 = parent.replies2 + [c]
parent.replies = parent.replies2 parent.replies = parent.replies2
c = parent c = parent
if c not in listing: if c.id not in all and c not in listing:
listing.append(c) all.add(c.id)
listing.add(c)
c.replies = c.replies2 c.replies = c.replies2
elif c.parent_submission: elif c.parent_submission:
replies = [] replies = set()
for x in c.replies: for x in c.replies:
if x.author_id == v.id: if x.id not in all and x.author_id == v.id:
x.voted = 1 x.voted = 1
replies.append(x) replies.add(x)
all.add(x.id)
c.replies = replies c.replies = replies
if c not in listing: if x.id not in all and c not in listing:
listing.append(c) all.add(c.id)
listing.add(c)
else: else:
if c.parent_comment: if c.parent_comment:
while c.level > 1: while c.level > 1:
all.add(c.id)
c = c.parent_comment c = c.parent_comment
if c not in listing: if c.id not in all and c not in listing:
listing.append(c) all.add(c.id)
listing.add(c)
if request.headers.get("Authorization"): return {"data":[x.json for x in listing]} if request.headers.get("Authorization"): return {"data":[x.json for x in listing]}