forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2022-02-04 07:30:46 +02:00
parent 04341c673d
commit 17cbb18ca1
2 changed files with 12 additions and 38 deletions

View File

@ -197,18 +197,12 @@ class Comment(Base):
@property
def replies(self):
r = self.__dict__.get("replies", None)
if r: r = [x for x in r if not x.author.shadowbanned]
if not r and r != []: r = sorted((x for x in self.child_comments if x.author and not x.author.shadowbanned and x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID)), key=lambda x: x.realupvotes, reverse=True)
return r
@replies.setter
def replies(self, value):
self.__dict__["replies"] = value
if self.replies2 != None: return [x for x in self.replies2 if not x.author.shadowbanned]
return sorted((x for x in self.child_comments if x.author and not x.author.shadowbanned and x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID)), key=lambda x: x.realupvotes, reverse=True)
@property
def replies2(self):
return self.__dict__.get("replies2", [])
return self.__dict__.get("replies2", None)
@replies2.setter
def replies2(self, value):

View File

@ -92,46 +92,26 @@ def notifications(v):
if not posts:
listing = []
for c in comments:
c.is_blocked = 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:
for x in c.replies:
if c.replies2 == None: c.replies2 = []
for x in c.child_comments:
if x.author_id == v.id:
x.voted = 1
c.replies2.append(x)
c.replies = []
while c.parent_comment and c.parent_comment.author_id == v.id:
parent = c.parent_comment
if c not in parent.replies2:
parent.replies2 = parent.replies2 + [c]
parent.replies = parent.replies2
if parent.replies2 == None: parent.replies2 = [c]
elif c not in parent.replies2: parent.replies2.append(c)
c = parent
if c not in listing:
listing.append(c)
c.replies = c.replies2
elif c.parent_submission:
for x in c.replies:
if x.author_id == v.id:
x.voted = 1
c.replies2.append(x)
c.replies = []
if c not in listing:
listing.append(c)
c.replies = c.replies2
else:
if c.parent_comment:
while c.level > 1:
c = c.parent_comment
while c.parent_comment:
c = c.parent_comment
if c not in listing: listing.append(c)
if c not in listing:
listing.append(c)
if request.headers.get("Authorization"): return {"data":[x.json for x in listing]}