parent
2bdb382ee5
commit
16c129e2b3
|
@ -141,7 +141,7 @@ class Comment(Base):
|
|||
replies = db.query(Comment).filter_by(parent_comment_id=self.id).order_by(Comment.stickied)
|
||||
if not self.parent_submission: sort='old'
|
||||
return sort_objects(sort, replies, Comment,
|
||||
include_shadowbanned=(v and v.can_see_shadowbanned)).all()
|
||||
include_shadowbanned=v.can_see_shadowbanned).all()
|
||||
|
||||
|
||||
@property
|
||||
|
@ -243,8 +243,8 @@ class Comment(Base):
|
|||
def realbody(self, v):
|
||||
if self.post and self.post.club and not (v and (v.paid_dues or v.id in [self.author_id, self.post.author_id] or (self.parent_comment and v.id == self.parent_comment.author_id))):
|
||||
return f"<p>{CC} ONLY</p>"
|
||||
if self.deleted_utc != 0 and not (v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or v.id == self.author.id)): return "[Deleted by user]"
|
||||
if self.is_banned and not (v and v.admin_level >= PERMS['POST_COMMENT_MODERATION']) and not (v and v.id == self.author.id): return ""
|
||||
if self.deleted_utc != 0 and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (v and v.id == self.author.id): return "[Deleted by user]"
|
||||
if self.is_banned and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] and not (v and v.id == self.author.id): return ""
|
||||
|
||||
body = self.body_html or ""
|
||||
|
||||
|
@ -298,8 +298,8 @@ class Comment(Base):
|
|||
def plainbody(self, v):
|
||||
if self.post and self.post.club and not (v and (v.paid_dues or v.id in [self.author_id, self.post.author_id] or (self.parent_comment and v.id == self.parent_comment.author_id))):
|
||||
return f"{CC} ONLY"
|
||||
if self.deleted_utc != 0 and not (v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or v.id == self.author.id)): return "[Deleted by user]"
|
||||
if self.is_banned and not (v and v.admin_level >= PERMS['POST_COMMENT_MODERATION']) and not (v and v.id == self.author.id): return ""
|
||||
if self.deleted_utc != 0 and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (v and v.id == self.author.id): return "[Deleted by user]"
|
||||
if self.is_banned and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] and not (v and v.id == self.author.id): return ""
|
||||
|
||||
body = self.body
|
||||
|
||||
|
@ -312,21 +312,13 @@ class Comment(Base):
|
|||
@lazy
|
||||
def collapse_for_user(self, v, path):
|
||||
if v and self.author_id == v.id: return False
|
||||
|
||||
if path == '/admin/removed/comments': return False
|
||||
|
||||
if self.author.shadowbanned and not v.shadowbanned: return True
|
||||
if '?context' in path or f'/{self.id}' in path: return False
|
||||
|
||||
if self.over_18 and not (v and v.over_18) and not (self.post and self.post.over_18): return True
|
||||
|
||||
if self.over_18 and not v.over_18 and not (self.post and self.post.over_18): return True
|
||||
if self.is_banned: return True
|
||||
|
||||
if self.author.shadowbanned and not (v and v.shadowbanned): return True
|
||||
|
||||
if (self.wordle_result) and (not self.body or len(self.body_html) <= 100) and 9 > self.level > 1: return True
|
||||
|
||||
if v and v.filter_words and self.body and any(x in self.body for x in v.filter_words): return True
|
||||
|
||||
if v.filter_words and self.body and any(x in self.body for x in v.filter_words): return True
|
||||
return False
|
||||
|
||||
@property
|
||||
|
@ -335,7 +327,7 @@ class Comment(Base):
|
|||
|
||||
@lazy
|
||||
def filtered_flags(self, v):
|
||||
return [f for f in self.flags if (v and v.shadowbanned) or not f.user.shadowbanned]
|
||||
return [f for f in self.flags if v.shadowbanned or not f.user.shadowbanned]
|
||||
|
||||
@lazy
|
||||
def active_flags(self, v):
|
||||
|
|
|
@ -271,8 +271,8 @@ class Submission(Base):
|
|||
@lazy
|
||||
def realbody(self, v, listing=False):
|
||||
if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"<p>{CC} ONLY</p>"
|
||||
if self.deleted_utc != 0 and not (v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or v.id == self.author.id)): return "[Deleted by user]"
|
||||
if self.is_banned and not (v and v.admin_level >= PERMS['POST_COMMENT_MODERATION']) and not (v and v.id == self.author.id): return ""
|
||||
if self.deleted_utc != 0 and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (v and v.id == self.author.id): return "[Deleted by user]"
|
||||
if self.is_banned and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] and not (v and v.id == self.author.id): return ""
|
||||
|
||||
body = self.body_html or ""
|
||||
|
||||
|
@ -328,8 +328,8 @@ class Submission(Base):
|
|||
|
||||
@lazy
|
||||
def plainbody(self, v):
|
||||
if self.deleted_utc != 0 and not (v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or v.id == self.author.id)): return "[Deleted by user]"
|
||||
if self.is_banned and not (v and v.admin_level >= PERMS['POST_COMMENT_MODERATION']) and not (v and v.id == self.author.id): return ""
|
||||
if self.deleted_utc != 0 and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (v and v.id == self.author.id): return "[Deleted by user]"
|
||||
if self.is_banned and not v.admin_level >= PERMS['POST_COMMENT_MODERATION'] and not (v and v.id == self.author.id): return ""
|
||||
if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"<p>{CC} ONLY</p>"
|
||||
|
||||
body = self.body
|
||||
|
@ -380,7 +380,7 @@ class Submission(Base):
|
|||
|
||||
@lazy
|
||||
def filtered_flags(self, v):
|
||||
return [f for f in self.flags if (v and v.shadowbanned) or not f.user.shadowbanned]
|
||||
return [f for f in self.flags if v.shadowbanned or not f.user.shadowbanned]
|
||||
|
||||
@lazy
|
||||
def active_flags(self, v):
|
||||
|
|
|
@ -419,8 +419,8 @@ class LoggedOutUser():
|
|||
'bannerurl': self.banner_url,
|
||||
'bio_html': self.bio_html_eager,
|
||||
'coins': self.coins,
|
||||
'post_count': 0 if self.shadowbanned and not (v and v.can_see_shadowbanned) else self.post_count,
|
||||
'comment_count': 0 if self.shadowbanned and not (v and v.can_see_shadowbanned) else self.comment_count,
|
||||
'post_count': 0 if self.shadowbanned and not v.can_see_shadowbanned else self.post_count,
|
||||
'comment_count': 0 if self.shadowbanned and not v.can_see_shadowbanned else self.comment_count,
|
||||
'badges': [x.path for x in self.badges],
|
||||
'created_date': self.created_date,
|
||||
}
|
||||
|
@ -521,15 +521,9 @@ class LoggedOutUser():
|
|||
|
||||
@lazy
|
||||
def show_sig(self, v):
|
||||
if not self.sig_html:
|
||||
return False
|
||||
|
||||
if not self.patron and SITE_NAME != 'WPD':
|
||||
return False
|
||||
|
||||
if v and (v.sigs_disabled or v.poor):
|
||||
return False
|
||||
|
||||
if not self.sig_html: return False
|
||||
if not self.patron and SITE_NAME != 'WPD': return False
|
||||
if v and (v.sigs_disabled or v.poor): return False
|
||||
return True
|
||||
|
||||
@property
|
||||
|
@ -587,7 +581,7 @@ class LoggedOutUser():
|
|||
if other.parent_submission and other.post.sub and not self.can_see(other.post.subr): return False
|
||||
# if other.parent_submission and not self.can_see(other.post): return False
|
||||
elif isinstance(other, Sub):
|
||||
return other.name != 'chudrama' or self.can_see_chudrama
|
||||
return other.name != 'chudrama' or self.can_see_chudrama # type: ignore
|
||||
elif isinstance(other, User):
|
||||
return bool(self and self.id == other.id) or self.can_see_shadowbanned or not other.shadowbanned
|
||||
return True
|
||||
|
@ -612,6 +606,17 @@ class LoggedOutUser():
|
|||
if self.truescore >= TRUESCORE_GHOST_LIMIT: return True
|
||||
if self.patron: return True
|
||||
return False
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def can_see_chat(self):
|
||||
if not self: return False
|
||||
if self.is_suspended_permanently: return False
|
||||
if not TRUESCORE_CHAT_LIMIT: return True
|
||||
if self.club_allowed: return True
|
||||
if self.truescore >= TRUESCORE_CHAT_LIMIT: return True
|
||||
if self.patron: return True
|
||||
return False
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
|
|
@ -51,7 +51,7 @@ def get_user(username:Optional[str], v:Optional[LoggedOutUser]=None, graceful=Fa
|
|||
|
||||
user = user.one_or_none()
|
||||
|
||||
if not user or (user.shadowbanned and not (include_shadowbanned or (v and v.can_see_shadowbanned))):
|
||||
if not user or (user.shadowbanned and not (include_shadowbanned or v.can_see_shadowbanned)):
|
||||
if graceful: return None
|
||||
abort(404)
|
||||
|
||||
|
@ -86,7 +86,7 @@ def get_account(id:Union[str, int], v:Optional[LoggedOutUser]=None, graceful=Fal
|
|||
|
||||
user = g.db.get(User, id)
|
||||
|
||||
if not user or (user.shadowbanned and not (include_shadowbanned or (v and v.can_see_shadowbanned))):
|
||||
if not user or (user.shadowbanned and not (include_shadowbanned or v.can_see_shadowbanned)):
|
||||
if not graceful: abort(404)
|
||||
else: return None
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ user_ids_to_socket_ids = {}
|
|||
@app.get("/chat")
|
||||
@is_not_permabanned
|
||||
def chat(v):
|
||||
if TRUESCORE_CHAT_LIMIT and v.truescore < TRUESCORE_CHAT_LIMIT and not v.club_allowed:
|
||||
if not v.can_see_chat:
|
||||
abort(403, f"Need at least {TRUESCORE_CHAT_LIMIT} truescore for access to chat.")
|
||||
return render_template("chat.html", v=v, messages=messages)
|
||||
|
||||
|
@ -50,7 +50,7 @@ def chat(v):
|
|||
@ratelimit_user("3/second;10/minute")
|
||||
def speak(data, v):
|
||||
if v.is_banned: return '', 403
|
||||
if TRUESCORE_CHAT_LIMIT and v.truescore < TRUESCORE_CHAT_LIMIT and not v.club_allowed: return '', 403
|
||||
if not v.can_see_chat: return '', 403
|
||||
|
||||
vname = v.username.lower()
|
||||
if vname in muted and not v.admin_level >= PERMS['CHAT_BYPASS_MUTE']:
|
||||
|
|
|
@ -47,7 +47,7 @@ def post_pid_comment_cid(v, cid, pid=None, anything=None, sub=None):
|
|||
|
||||
post = get_post(pid, v=v)
|
||||
|
||||
if post.over_18 and not (v and v.over_18) and not session.get('over_18', 0) >= int(time.time()):
|
||||
if post.over_18 and not v.over_18 and not session.get('over_18', 0) >= int(time.time()):
|
||||
if v and v.client: abort(403, "This content is not suitable for some users and situations.")
|
||||
else: return render_template("errors/nsfw.html", v=v), 403
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ def front_all(v, sub=None, subdomain=None):
|
|||
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='', gt=0, lt=0, sub=None, site=None, pins=True, holes=True):
|
||||
posts = g.db.query(Submission)
|
||||
|
||||
if v and v.hidevotedon:
|
||||
if v.hidevotedon:
|
||||
posts = posts.outerjoin(Vote,
|
||||
and_(Vote.submission_id == Submission.id, Vote.user_id == v.id)
|
||||
).filter(Vote.submission_id == None)
|
||||
|
@ -137,7 +137,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
|||
posts=posts.filter(not_(Submission.title.ilike(f'%{word}%')))
|
||||
|
||||
posts = sort_objects(sort, posts, Submission,
|
||||
include_shadowbanned=(v and v.can_see_shadowbanned))
|
||||
include_shadowbanned=v.can_see_shadowbanned)
|
||||
|
||||
if v: size = v.frontsize or 0
|
||||
else: size = PAGE_SIZE
|
||||
|
@ -255,7 +255,7 @@ def comment_idlist(v=None, page=1, sort="new", t="all", gt=0, lt=0, site=None):
|
|||
comments = apply_time_filter(t, comments, Comment)
|
||||
|
||||
comments = sort_objects(sort, comments, Comment,
|
||||
include_shadowbanned=(v and v.can_see_shadowbanned))
|
||||
include_shadowbanned=v.can_see_shadowbanned)
|
||||
|
||||
comments = comments.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE + 1).all()
|
||||
return [x[0] for x in comments]
|
||||
|
|
|
@ -157,7 +157,7 @@ def post_id(v, pid, anything=None, sub=None):
|
|||
pinned = [c[0] for c in comments.filter(Comment.stickied != None).all()]
|
||||
comments = comments.filter(Comment.level == 1, Comment.stickied == None)
|
||||
comments = sort_objects(sort, comments, Comment,
|
||||
include_shadowbanned=(v and v.can_see_shadowbanned))
|
||||
include_shadowbanned=v.can_see_shadowbanned)
|
||||
comments = [c[0] for c in comments.all()]
|
||||
else:
|
||||
pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.stickied != None).all()
|
||||
|
@ -247,7 +247,7 @@ def viewmore(v, pid, sort, offset):
|
|||
comments, output = get_comments_v_properties(v, True, None, Comment.parent_submission == pid, Comment.stickied == None, Comment.id.notin_(ids), Comment.level < 10)
|
||||
comments = comments.filter(Comment.level == 1)
|
||||
comments = sort_objects(sort, comments, Comment,
|
||||
include_shadowbanned=(v and v.can_see_shadowbanned))
|
||||
include_shadowbanned=v.can_see_shadowbanned)
|
||||
|
||||
comments = [c[0] for c in comments.all()]
|
||||
else:
|
||||
|
|
|
@ -153,7 +153,7 @@ def searchposts(v):
|
|||
posts = apply_time_filter(t, posts, Submission)
|
||||
|
||||
posts = sort_objects(sort, posts, Submission,
|
||||
include_shadowbanned=(v and v.can_see_shadowbanned))
|
||||
include_shadowbanned=v.can_see_shadowbanned)
|
||||
|
||||
total = posts.count()
|
||||
|
||||
|
@ -255,7 +255,7 @@ def searchcomments(v):
|
|||
comments = comments.filter(Comment.created_utc < before)
|
||||
|
||||
comments = sort_objects(sort, comments, Comment,
|
||||
include_shadowbanned=(v and v.can_see_shadowbanned))
|
||||
include_shadowbanned=v.can_see_shadowbanned)
|
||||
|
||||
total = comments.count()
|
||||
|
||||
|
|
|
@ -670,7 +670,7 @@ def visitors(v):
|
|||
|
||||
@cache.memoize(timeout=86400)
|
||||
def userpagelisting(user:User, site=None, v=None, page:int=1, sort="new", t="all"):
|
||||
if user.shadowbanned and not (v and v.can_see_shadowbanned): return []
|
||||
if user.shadowbanned and not v.can_see_shadowbanned: return []
|
||||
posts = g.db.query(Submission.id).filter_by(author_id=user.id, is_pinned=False)
|
||||
if not (v and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or v.id == user.id)):
|
||||
posts = posts.filter_by(is_banned=False, private=False, ghost=False, deleted_utc=0)
|
||||
|
@ -803,7 +803,7 @@ def u_username_comments(username, v=None):
|
|||
comments = apply_time_filter(t, comments, Comment)
|
||||
|
||||
comments = sort_objects(sort, comments, Comment,
|
||||
include_shadowbanned=(v and v.can_see_shadowbanned))
|
||||
include_shadowbanned=v.can_see_shadowbanned)
|
||||
|
||||
comments = comments.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE+1).all()
|
||||
ids = [x.id for x in comments]
|
||||
|
|
Loading…
Reference in New Issue