profile views and modmail/hole creation notifications

remotes/1693176582716663532/tmp_refs/heads/watchparty
justcool393 2022-10-05 22:07:38 -07:00
parent f531b12727
commit 68851ed986
5 changed files with 17 additions and 14 deletions

View File

@ -903,7 +903,7 @@ class User(Base):
def viewers_recorded(self):
if SITE_NAME == 'WPD': # WPD gets profile views
return True
elif self.admin_level >= 2: # Admins get profile views
elif self.admin_level >= PERMS['VIEW_PROFILE_VIEWS']: # Admins get profile views
return True
elif self.patron: # Patrons get profile views as a perk
return True

View File

@ -154,6 +154,7 @@ PERMS = { # Minimum admin_level to perform action.
'VIEW_CHUDRAMA': 1,
'VIEW_PRIVATE_PROFILES': 2,
'VIEW_ALTS': 2,
'VIEW_PROFILE_VIEWS': 2,
'PRINT_MARSEYBUX_FOR_KIPPY_ON_PCMEMES': 3,
'VIEW_ACTIVE_USERS': 2,
'MERGE_USERS': 3, # note: extra check for Aevann
@ -169,7 +170,9 @@ PERMS = { # Minimum admin_level to perform action.
'CACHE_DUMP_INTERNAL': 2,
'DOMAINS_BAN': 3,
'NOTIFICATIONS_HOLE_INACTIVITY_DELETION': 2,
'NOTIFICATIONS_HOLE_CREATION': 2,
'NOTIFICATIONS_FROM_SHADOWBANNED_USERS': 3,
'NOTIFICATIONS_MODMAIL': 3,
}
FEATURES = {

View File

@ -235,7 +235,7 @@ def submit_contact(v):
g.db.flush()
new_comment.top_comment_id = new_comment.id
admins = g.db.query(User).filter(User.admin_level > 2)
admins = g.db.query(User).filter(User.admin_level >= PERMS['NOTIFICATIONS_MODMAIL'])
if SITE == 'watchpeopledie.co':
admins = admins.filter(User.id != AEVANN_ID)

View File

@ -345,7 +345,7 @@ def create_sub2(v):
mod = Mod(user_id=v.id, sub=sub.name)
g.db.add(mod)
admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level > 1, User.id != v.id).all()]
admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_HOLE_CREATION'], User.id != v.id).all()]
for admin in admins:
send_repeatable_notification(admin, f":!marseyparty: /h/{sub} has been created by @{v.username} :marseyparty:")

View File

@ -62,7 +62,7 @@ gevent.spawn(leaderboard_thread)
@auth_required
def upvoters_posts(v, username, uid):
u = get_user(username, v=v, include_shadowbanned=False)
if u.is_private and (not v or (v.id != u.id and v.admin_level < 2 and not v.eye)): abort(403)
if u.is_private and (not v or (v.id != u.id and v.admin_level < PERMS['VIEW_PRIVATE_PROFILES'] and not v.eye)): abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']): abort(403)
id = u.id
uid = int(uid)
@ -84,7 +84,7 @@ def upvoters_posts(v, username, uid):
@auth_required
def upvoters_comments(v, username, uid):
u = get_user(username, v=v, include_shadowbanned=False)
if u.is_private and (not v or (v.id != u.id and v.admin_level < 2 and not v.eye)): abort(403)
if u.is_private and (not v or (v.id != u.id and v.admin_level < PERMS['VIEW_PRIVATE_PROFILES'] and not v.eye)): abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']): abort(403)
id = u.id
uid = int(uid)
@ -106,7 +106,7 @@ def upvoters_comments(v, username, uid):
@auth_required
def downvoters_posts(v, username, uid):
u = get_user(username, v=v, include_shadowbanned=False)
if u.is_private and (not v or (v.id != u.id and v.admin_level < 2 and not v.eye)): abort(403)
if u.is_private and (not v or (v.id != u.id and v.admin_level < PERMS['VIEW_PRIVATE_PROFILES'] and not v.eye)): abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']): abort(403)
id = u.id
uid = int(uid)
@ -128,7 +128,7 @@ def downvoters_posts(v, username, uid):
@auth_required
def downvoters_comments(v, username, uid):
u = get_user(username, v=v, include_shadowbanned=False)
if u.is_private and (not v or (v.id != u.id and v.admin_level < 2 and not v.eye)): abort(403)
if u.is_private and (not v or (v.id != u.id and v.admin_level < PERMS['VIEW_PRIVATE_PROFILES'] and not v.eye)): abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']): abort(403)
id = u.id
uid = int(uid)
@ -153,7 +153,7 @@ def downvoters_comments(v, username, uid):
@auth_required
def upvoting_posts(v, username, uid):
u = get_user(username, v=v, include_shadowbanned=False)
if u.is_private and (not v or (v.id != u.id and v.admin_level < 2 and not v.eye)): abort(403)
if u.is_private and (not v or (v.id != u.id and v.admin_level < PERMS['VIEW_PRIVATE_PROFILES'] and not v.eye)): abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']): abort(403)
id = u.id
uid = int(uid)
@ -175,7 +175,7 @@ def upvoting_posts(v, username, uid):
@auth_required
def upvoting_comments(v, username, uid):
u = get_user(username, v=v, include_shadowbanned=False)
if u.is_private and (not v or (v.id != u.id and v.admin_level < 2 and not v.eye)): abort(403)
if u.is_private and (not v or (v.id != u.id and v.admin_level < PERMS['VIEW_PRIVATE_PROFILES'] and not v.eye)): abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']): abort(403)
id = u.id
uid = int(uid)
@ -197,7 +197,7 @@ def upvoting_comments(v, username, uid):
@auth_required
def downvoting_posts(v, username, uid):
u = get_user(username, v=v, include_shadowbanned=False)
if u.is_private and (not v or (v.id != u.id and v.admin_level < 2 and not v.eye)): abort(403)
if u.is_private and (not v or (v.id != u.id and v.admin_level < PERMS['VIEW_PRIVATE_PROFILES'] and not v.eye)): abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']): abort(403)
id = u.id
uid = int(uid)
@ -219,7 +219,7 @@ def downvoting_posts(v, username, uid):
@auth_required
def downvoting_comments(v, username, uid):
u = get_user(username, v=v, include_shadowbanned=False)
if u.is_private and (not v or (v.id != u.id and v.admin_level < 2 and not v.eye)): abort(403)
if u.is_private and (not v or (v.id != u.id and v.admin_level < PERMS['VIEW_PRIVATE_PROFILES'] and not v.eye)): abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']): abort(403)
id = u.id
uid = int(uid)
@ -241,7 +241,7 @@ def downvoting_comments(v, username, uid):
@auth_required
def user_upvoted_posts(v, username):
u = get_user(username, v=v, include_shadowbanned=False)
if u.is_private and (not v or (v.id != u.id and v.admin_level < 2 and not v.eye)): abort(403)
if u.is_private and (not v or (v.id != u.id and v.admin_level < PERMS['VIEW_PRIVATE_PROFILES'] and not v.eye)): abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']): abort(403)
page = max(1, int(request.values.get("page", 1)))
@ -267,7 +267,7 @@ def user_upvoted_posts(v, username):
@auth_required
def user_upvoted_comments(v, username):
u = get_user(username, v=v, include_shadowbanned=False)
if u.is_private and (not v or (v.id != u.id and v.admin_level < 2 and not v.eye)): abort(403)
if u.is_private and (not v or (v.id != u.id and v.admin_level < PERMS['VIEW_PRIVATE_PROFILES'] and not v.eye)): abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']): abort(403)
page = max(1, int(request.values.get("page", 1)))
@ -877,7 +877,7 @@ def messagereply(v):
if c.top_comment.sentto == 2:
admins = g.db.query(User.id).filter(User.admin_level > 2, User.id != v.id)
admins = g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_MODMAIL'], User.id != v.id)
if SITE == 'watchpeopledie.co':
admins = admins.filter(User.id != AEVANN_ID)