Make PIN_LIMIT a per-site constant.

master
Snakes 2022-06-02 19:45:33 -04:00
parent 6b9a133204
commit 379ae664a3
2 changed files with 5 additions and 2 deletions

View File

@ -128,6 +128,8 @@ AGENDAPOSTER_PHRASE = 'trans lives matter'
AGENDAPOSTER_MSG = """Hi @{username},\n\nYour {type} has been automatically removed because you forgot to include `{AGENDAPOSTER_PHRASE}`.\n\nDon't worry, we're here to help! We won't let you post or comment anything that doesn't express your love and acceptance towards the trans community. Feel free to resubmit your {type} with `{AGENDAPOSTER_PHRASE}` included. \n\n*This is an automated message; if you need help, you can message us [here](/contact).*""" AGENDAPOSTER_MSG = """Hi @{username},\n\nYour {type} has been automatically removed because you forgot to include `{AGENDAPOSTER_PHRASE}`.\n\nDon't worry, we're here to help! We won't let you post or comment anything that doesn't express your love and acceptance towards the trans community. Feel free to resubmit your {type} with `{AGENDAPOSTER_PHRASE}` included. \n\n*This is an automated message; if you need help, you can message us [here](/contact).*"""
PIN_LIMIT = 3
if SITE in {'rdrama.net','devrama.xyz'}: if SITE in {'rdrama.net','devrama.xyz'}:
HOLE_COST = 200000 HOLE_COST = 200000
NOTIFICATIONS_ID = 1046 NOTIFICATIONS_ID = 1046
@ -176,6 +178,7 @@ if SITE in {'rdrama.net','devrama.xyz'}:
elif SITE == "pcmemes.net": elif SITE == "pcmemes.net":
HOLE_COST = 10000 HOLE_COST = 10000
PIN_LIMIT = 6
NOTIFICATIONS_ID = 1046 NOTIFICATIONS_ID = 1046
AUTOJANNY_ID = 1050 AUTOJANNY_ID = 1050
SNAPPY_ID = 261 SNAPPY_ID = 261

View File

@ -1356,11 +1356,11 @@ def sticky_post(post_id, v):
post = g.db.query(Submission).filter_by(id=post_id).one_or_none() post = g.db.query(Submission).filter_by(id=post_id).one_or_none()
if post and not post.stickied: if post and not post.stickied:
pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False).count() pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False).count()
if pins > 2: if pins >= PIN_LIMIT:
if v.admin_level > 2: if v.admin_level > 2:
post.stickied = v.username post.stickied = v.username
post.stickied_utc = int(time.time()) + 3600 post.stickied_utc = int(time.time()) + 3600
else: return {"error": "Can't exceed 3 pinned posts limit!"}, 403 else: return {"error": f"Can't exceed {PIN_LIMIT} pinned posts limit!"}, 403
else: post.stickied = v.username else: post.stickied = v.username
g.db.add(post) g.db.add(post)