rDrama/files/helpers/can_see.py

61 lines
2.8 KiB
Python
Raw Permalink Normal View History

2023-10-05 10:14:59 +00:00
from .config.const import *
2023-10-05 10:09:58 +00:00
from files.classes.post import Post
from files.classes.comment import Comment
2023-10-07 17:55:50 +00:00
from files.classes.hole import Hole
2023-10-05 10:09:58 +00:00
from flask import request
2024-05-03 02:09:47 +00:00
#DELETE_ME_PLS
2024-05-04 02:41:46 +00:00
if SITE_NAME == 'rDrama':
words_to_hide = ('israel', 'isreal', 'palest', 'muslim', 'islam', 'hamas', 'jew', 'zion', 'gaza', 'rafah', 'isis', 'terror', 'iraq', 'allah', 'mohammad', 'muhammad', 'mohammed', 'muhammed', 'mohamad', 'muhamad', 'mohamed', 'muhamed', 'trans', 'train', 'tranny', 'troon', 'rowdy', 'nigger', 'bipoc', 'rape', 'rapist', 'wpd', 'watchpeopledie')
else:
words_to_hide = ('israel', 'isreal', 'palest', 'muslim', 'islam', 'hamas', 'jew', 'zion', 'gaza', 'rafah', 'isis', 'terror', 'iraq', 'allah', 'mohammad', 'muhammad', 'mohammed', 'muhammed', 'mohamad', 'muhamad', 'mohamed', 'muhamed', 'trans', 'train', 'tranny', 'troon', 'rowdy', 'nigger', 'bipoc', 'rape', 'rapist')
2024-05-03 02:09:47 +00:00
2024-03-05 00:55:20 +00:00
def can_see(user, obj):
if isinstance(obj, (Post, Comment)):
2024-05-03 02:09:47 +00:00
#DELETE_ME_PLS
if not user:
if obj.nsfw:
return False
if any((x in obj.body.lower() for x in words_to_hide)):
return False
2024-05-03 02:25:49 +00:00
if isinstance(obj, Post) and any((x in obj.title.lower() for x in words_to_hide)):
return False
2024-03-05 00:55:20 +00:00
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):
2023-10-05 10:09:58 +00:00
return False
if request.headers.get("Cf-Ipcountry") == 'NZ':
2024-03-05 00:55:20 +00:00
if 'christchurch' in obj.title.lower():
2023-10-05 10:09:58 +00:00
return False
2024-03-05 00:55:20 +00:00
if SITE == 'watchpeopledie.tv' and obj.id in {5, 17212, 22653, 23814}:
2023-10-05 10:09:58 +00:00
return False
else:
2024-03-05 01:16:47 +00:00
if obj.pinned == "Admin Note":
2024-04-05 07:45:25 +00:00
return user and user.admin_level >= PERMS['ADMIN_NOTES']
2024-03-05 00:55:20 +00:00
if hasattr(obj, 'is_blocking') and obj.is_blocking and not request.path.endswith(f'/{obj.id}'):
2023-10-05 10:09:58 +00:00
return False
2024-03-05 00:55:20 +00:00
if obj.parent_post:
return can_see(user, obj.post)
2023-10-05 10:09:58 +00:00
else:
2024-03-05 00:55:20 +00:00
if not user and not obj.wall_user_id: return False
2023-10-05 10:09:58 +00:00
2024-03-05 00:55:20 +00:00
if obj.sentto:
if obj.sentto == MODMAIL_ID:
if obj.top_comment.author_id == user.id: return True
2023-10-05 10:09:58 +00:00
return user.admin_level >= PERMS['VIEW_MODMAIL']
2024-03-08 08:10:23 +00:00
if obj.sentto != user.id:
2023-10-05 10:09:58 +00:00
return user.admin_level >= PERMS['BLACKJACK_NOTIFICATIONS']
2024-03-05 00:55:20 +00:00
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
2024-05-03 02:09:47 +00:00
#DELETE_ME_PLS
if obj.name in {'sandshit', 'isis', 'facism', 'furry', 'fatpeoplehate', 'toomanyxchromosomes', 'drugs', 'faggot', 'spalspace', 'deadniggerstorage'}: return bool(user)
2024-03-05 00:55:20 +00:00
elif obj.__class__.__name__ == 'User':
2024-05-03 02:09:47 +00:00
#DELETE_ME_PLS
2024-05-03 14:52:00 +00:00
if not user and obj.id == 21238: return False
2024-03-05 00:55:20 +00:00
return not obj.shadowbanned or (user and user.id == obj.id) or (user and user.admin_level >= PERMS['USER_SHADOWBAN'])
2023-10-05 10:09:58 +00:00
return True