convert a couple of the old constantified permissions to the new system

i don't want to break something so i'm keeping one of them for now but it just links
master
justcool393 2022-10-07 01:50:20 -07:00
parent 91cb50db38
commit 48384ba8e5
5 changed files with 11 additions and 11 deletions

View File

@ -379,7 +379,7 @@ class User(Base):
@property
@lazy
def can_view_offsitementions(self):
return self.offsitementions or self.admin_level >= REDDIT_NOTIFS_JL_MIN
return self.offsitementions or self.admin_level >= PERMS['NOTIFICATIONS_REDDIT']
@property
@lazy

View File

@ -186,6 +186,8 @@ PERMS = { # Minimum admin_level to perform action.
'NOTIFICATIONS_HOLE_CREATION': 2,
'NOTIFICATIONS_FROM_SHADOWBANNED_USERS': 3,
'NOTIFICATIONS_MODMAIL': 3,
'NOTIFICATIONS_MODERATOR_ACTIONS': 2,
'NOTIFICATIONS_REDDIT': 1,
'NOTIFICATIONS_SPECIFIC_WPD_COMMENTS': 1,
'MESSAGE_BLOCKED_USERS': 1,
'APPS_MODERATION': 3,
@ -945,11 +947,8 @@ FACTCHECK_REPLIES = ('<b style="color:#6023f8">Factcheck: This claim has been co
EIGHTBALL_REPLIES = ('<b style="color:#7FEC11">The 8-Ball Says: It is certain.</b>', '<b style="color:#7FEC11">The 8-Ball Says: It is decidedly so.</b>', '<b style="color:#7FEC11">The 8-Ball Says: Without a doubt.</b>', '<b style="color:#7FEC11">The 8-Ball Says: Yes definitely.</b>', '<b style="color:#7FEC11">The 8-Ball Says: You may rely on it.</b>', '<b style="color:#7FEC11">The 8-Ball Says: As I see it, yes.</b>', '<b style="color:#7FEC11">The 8-Ball Says: Most likely.</b>', '<b style="color:#7FEC11">The 8-Ball Says: Outlook good.</b>', '<b style="color:#7FEC11">The 8-Ball Says: Yes.</b>', '<b style="color:#7FEC11">The 8-Ball Says: Signs point to yes.</b>', '<b style="color:#E7890C">The 8-Ball Says: Reply hazy, try again.</b>', '<b style="color:#E7890C">The 8-Ball Says: Ask again later.</b>', '<b style="color:#E7890C">The 8-Ball Says: Better not tell you now.</b>', '<b style="color:#E7890C">The 8-Ball Says: Cannot predict now.</b>', '<b style="color:#E7890C">The 8-Ball Says: Concentrate and ask again.</b>', '<b style="color:#FD4D32">The 8-Ball Says: Don\'t count on it.</b>', '<b style="color:#FD4D32">The 8-Ball Says: My reply is no.</b>', '<b style="color:#FD4D32">The 8-Ball Says: My sources say no.</b>', '<b style="color:#FD4D32">The 8-Ball Says: Outlook not so good.</b>', '<b style="color:#FD4D32">The 8-Ball Says: Very doubtful.</b>')
NOTIF_MODACTION_JL_MIN = PERMS['NOTIFICATIONS_MODERATOR_ACTIONS']
NOTIF_MODACTION_JL_MIN = 2
REDDIT_NOTIFS_JL_MIN = 1
REDDIT_NOTIFS_SITE = set()
REDDIT_NOTIFS_USERS = {}

View File

@ -8,15 +8,16 @@ from files.classes.comment import Comment
from files.classes.notifications import Notification
from files.helpers.sanitize import sanitize
# https://api.pushshift.io/meta provides key server_ratelimit_per_minute
# At time of writing, the ratelimit is 120 req/min. We get nowhere near this
# Note: while https://api.pushshift.io/meta provides the key
# server_ratelimit_per_minute, in practice Cloudflare puts stricter,
# unofficially documented limits at around 60/minute. We get nowhere near this
# with current keyword quantities. If this ever changes, consider reading the
# value from /meta and doing a random selection of keywords.
# value from /meta (or just guessing) and doing a random selection of keywords.
def offsite_mentions_task():
if const.REDDIT_NOTIFS_SITE:
row_send_to = g.db.query(User.id) \
.filter(or_(User.admin_level >= const.REDDIT_NOTIFS_JL_MIN,
.filter(or_(User.admin_level >= const.PERMS['NOTIFICATIONS_REDDIT'],
User.offsitementions == True)).all()
send_to = [x[0] for x in row_send_to]

View File

@ -172,7 +172,7 @@ def notifications_posts(v):
@app.get("/notifications/modactions")
@admin_level_required(NOTIF_MODACTION_JL_MIN)
@admin_level_required(PERMS['NOTIFICATIONS_MODERATOR_ACTIONS'])
def notifications_modactions(v):
try: page = max(int(request.values.get("page", 1)), 1)
except: page = 1

View File

@ -30,7 +30,7 @@
Posts {% if v.post_notifications_count %}<span class="font-weight-bold" style="color:#0000ff">({{v.post_notifications_count}})</span>{% endif %}
</a>
</li>
{% if v.admin_level >= NOTIF_MODACTION_JL_MIN %}
{% if v.admin_level >= PERMS['NOTIFICATIONS_MODERATOR_ACTIONS'] %}
<li class="nav-item">
<a class="nav-link py-3{% if request.path == '/notifications/modactions' %} active{% endif %}" href="/notifications/modactions">
Modactions {% if v.modaction_notifications_count %}<span class="font-weight-bold" style="color:#1ad80d">({{v.modaction_notifications_count}})</span>{% endif %}