From 5e756111db0975aac1457729194f56be7490fbd2 Mon Sep 17 00:00:00 2001 From: Aevann Date: Tue, 5 Mar 2024 02:55:20 +0200 Subject: [PATCH] other -> obj --- files/helpers/can_see.py | 50 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/files/helpers/can_see.py b/files/helpers/can_see.py index bbc888cf7..5c37866cd 100644 --- a/files/helpers/can_see.py +++ b/files/helpers/can_see.py @@ -7,45 +7,45 @@ from flask import request #DELETE_ME_PLS words_to_hide = ('israel', 'isreal', 'palestin', 'muslim', 'islam', 'hamas', 'jew', 'zion', 'gaza', 'rafah', 'isis', 'terror', 'iraq', 'allah', 'mohammad', 'muhammad', 'mohammed', 'muhammed', 'mohamad', 'muhamad', 'mohamed', 'muhamed') -def can_see(user, other): - if isinstance(other, (Post, Comment)): +def can_see(user, obj): + if isinstance(obj, (Post, Comment)): #DELETE_ME_PLS if not user: - if other.nsfw: + if obj.nsfw: return False - if any((x in other.body.lower() for x in words_to_hide)): + if any((x in obj.body.lower() for x in words_to_hide)): return False - if isinstance(other, Post) and other.hole == 'sandshit': + if isinstance(obj, Post) and obj.hole == 'sandshit': return False - if not can_see(user, other.author): return False - if user and user.id == other.author_id: return True - if isinstance(other, Post): - if other.hole and not can_see(user, other.hole_obj): + if not can_see(user, obj.author): return False + if user and user.id == obj.author_id: return True + if isinstance(obj, Post): + if obj.hole and not can_see(user, obj.hole_obj): return False if request.headers.get("Cf-Ipcountry") == 'NZ': - if 'christchurch' in other.title.lower(): + if 'christchurch' in obj.title.lower(): return False - if SITE == 'watchpeopledie.tv' and other.id in {5, 17212, 22653, 23814}: + if SITE == 'watchpeopledie.tv' and obj.id in {5, 17212, 22653, 23814}: return False else: - if hasattr(other, 'is_blocking') and other.is_blocking and not request.path.endswith(f'/{other.id}'): + if hasattr(obj, 'is_blocking') and obj.is_blocking and not request.path.endswith(f'/{obj.id}'): return False - if other.parent_post: - return can_see(user, other.post) + if obj.parent_post: + return can_see(user, obj.post) else: - if not user and not other.wall_user_id: return False + if not user and not obj.wall_user_id: return False - if other.sentto: - if other.sentto == MODMAIL_ID: - if other.top_comment.author_id == user.id: return True + if obj.sentto: + if obj.sentto == MODMAIL_ID: + if obj.top_comment.author_id == user.id: return True return user.admin_level >= PERMS['VIEW_MODMAIL'] - if other.sentto != user.id: + if obj.sentto != user.id: return user.admin_level >= PERMS['BLACKJACK_NOTIFICATIONS'] - elif isinstance(other, Hole): - if other.name == 'chudrama': return bool(user) and user.can_see_chudrama - if other.name == 'countryclub': return bool(user) and user.can_see_countryclub - if other.name == 'highrollerclub': return bool(user) and user.can_see_highrollerclub - elif other.__class__.__name__ == 'User': - return not other.shadowbanned or (user and user.id == other.id) or (user and user.admin_level >= PERMS['USER_SHADOWBAN']) + elif isinstance(obj, Hole): + if obj.name == 'chudrama': return bool(user) and user.can_see_chudrama + if obj.name == 'countryclub': return bool(user) and user.can_see_countryclub + if obj.name == 'highrollerclub': return bool(user) and user.can_see_highrollerclub + elif obj.__class__.__name__ == 'User': + return not obj.shadowbanned or (user and user.id == obj.id) or (user and user.admin_level >= PERMS['USER_SHADOWBAN']) return True