forked from rDrama/rDrama
sfd
parent
04341c673d
commit
17cbb18ca1
|
@ -197,18 +197,12 @@ class Comment(Base):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def replies(self):
|
def replies(self):
|
||||||
r = self.__dict__.get("replies", None)
|
if self.replies2 != None: return [x for x in self.replies2 if not x.author.shadowbanned]
|
||||||
if r: r = [x for x in r 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)
|
||||||
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
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def replies2(self):
|
def replies2(self):
|
||||||
return self.__dict__.get("replies2", [])
|
return self.__dict__.get("replies2", None)
|
||||||
|
|
||||||
@replies2.setter
|
@replies2.setter
|
||||||
def replies2(self, value):
|
def replies2(self, value):
|
||||||
|
|
|
@ -92,46 +92,26 @@ def notifications(v):
|
||||||
if not posts:
|
if not posts:
|
||||||
listing = []
|
listing = []
|
||||||
for c in comments:
|
for c in comments:
|
||||||
c.is_blocked = False
|
if c.parent_submission:
|
||||||
c.is_blocking = False
|
|
||||||
if c.parent_submission and c.parent_comment and c.parent_comment.author_id == v.id:
|
|
||||||
|
|
||||||
for x in c.replies:
|
if c.replies2 == None: c.replies2 = []
|
||||||
|
for x in c.child_comments:
|
||||||
if x.author_id == v.id:
|
if x.author_id == v.id:
|
||||||
x.voted = 1
|
x.voted = 1
|
||||||
c.replies2.append(x)
|
c.replies2.append(x)
|
||||||
|
|
||||||
c.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
|
||||||
if c not in parent.replies2:
|
if parent.replies2 == None: parent.replies2 = [c]
|
||||||
parent.replies2 = parent.replies2 + [c]
|
elif c not in parent.replies2: parent.replies2.append(c)
|
||||||
parent.replies = parent.replies2
|
|
||||||
c = parent
|
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:
|
else:
|
||||||
if c.parent_comment:
|
while c.parent_comment:
|
||||||
while c.level > 1:
|
|
||||||
c = c.parent_comment
|
c = c.parent_comment
|
||||||
|
|
||||||
if c not in listing:
|
if c not in listing: listing.append(c)
|
||||||
listing.append(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]}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue