allow admins to apply progstack

pull/93/head
Aevann 2023-01-23 14:40:44 +02:00
parent 47dc6da582
commit bdaced6c10
6 changed files with 43 additions and 16 deletions

View File

@ -53,6 +53,7 @@ blackjack2 = environ.get("BLACKJACK2", "").strip()
FP = environ.get("FP", "").strip() FP = environ.get("FP", "").strip()
KOFI_TOKEN = environ.get("KOFI_TOKEN", "").strip() KOFI_TOKEN = environ.get("KOFI_TOKEN", "").strip()
KOFI_LINK = environ.get("KOFI_LINK", "").strip() KOFI_LINK = environ.get("KOFI_LINK", "").strip()
PROGSTACK_MUL = float(environ.get("PROGSTACK_MUL", 2.0))
class Service(Enum): class Service(Enum):
RDRAMA = auto() RDRAMA = auto()
@ -472,9 +473,10 @@ PERMS = { # Minimum admin_level to perform action.
'UPDATE_ASSETS': 4, 'UPDATE_ASSETS': 4,
'VIEW_PATRONS': 4, 'VIEW_PATRONS': 4,
'BLACKJACK_NOTIFICATIONS': 4, 'BLACKJACK_NOTIFICATIONS': 4,
'IGNORE_BADGE_BLACKLIST': 4, 'IGNORE_BADGE_BLACKLIST': 4,
'PROGSTACK': 4,
'SEE_GHOST_VOTES': 5, 'SEE_GHOST_VOTES': 5,
'MODS_EVERY_HOLE': 5 'MODS_EVERY_HOLE': 5,
} }
FEATURES = { FEATURES = {
@ -614,6 +616,8 @@ LONGPOSTBOT_ID = 3
ZOZBOT_ID = 4 ZOZBOT_ID = 4
PIZZASHILL_ID = 0 PIZZASHILL_ID = 0
IMPASSIONATA_ID = 0 IMPASSIONATA_ID = 0
PROGSTACK_ID = 4
CARP_ID = 0 CARP_ID = 0
AEVANN_ID = 0 AEVANN_ID = 0
SNAKES_ID = 0 SNAKES_ID = 0
@ -709,6 +713,7 @@ if SITE == 'rdrama.net':
ZOZBOT_ID = 1833 ZOZBOT_ID = 1833
PIZZASHILL_ID = 2424 PIZZASHILL_ID = 2424
IMPASSIONATA_ID = 5800 IMPASSIONATA_ID = 5800
PROGSTACK_ID = 15531
CARP_ID = 995 CARP_ID = 995
AEVANN_ID = 1 AEVANN_ID = 1
SNAKES_ID = 10288 SNAKES_ID = 10288

View File

@ -1,5 +1,6 @@
import time import time
from urllib.parse import quote, urlencode from urllib.parse import quote, urlencode
from math import floor
from sqlalchemy import nullslast from sqlalchemy import nullslast
from sqlalchemy.exc import IntegrityError from sqlalchemy.exc import IntegrityError
@ -1269,6 +1270,17 @@ def unmute_user(v:User, user_id):
return {"message": f"@{user.username} has been unmuted!"} return {"message": f"@{user.username} has been unmuted!"}
@app.post("/admin/progstack/<int:post_id>")
@limiter.limit(DEFAULT_RATELIMIT_SLOWER)
@limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=get_ID)
@admin_level_required(PERMS['PROGSTACK'])
def progstack(post_id, v):
post = get_post(post_id)
post.is_approved = PROGSTACK_ID
post.realupvotes = floor(target.realupvotes * PROGSTACK_MUL)
g.db.add(post)
cache.delete_memoized(frontlist)
return {"message": "Progressive stack applied!"}
@app.post("/remove_post/<int:post_id>") @app.post("/remove_post/<int:post_id>")
@limiter.limit(DEFAULT_RATELIMIT_SLOWER) @limiter.limit(DEFAULT_RATELIMIT_SLOWER)

View File

@ -114,7 +114,7 @@ def inject_constants():
"approved_embed_hosts":approved_embed_hosts, "approved_embed_hosts":approved_embed_hosts,
"site_settings":get_settings(), "EMAIL":EMAIL, "max": max, "min": min, "user_can_see":User.can_see, "site_settings":get_settings(), "EMAIL":EMAIL, "max": max, "min": min, "user_can_see":User.can_see,
"TELEGRAM_ID":TELEGRAM_ID, "EMAIL_REGEX_PATTERN":EMAIL_REGEX_PATTERN, "TELEGRAM_ID":TELEGRAM_ID, "EMAIL_REGEX_PATTERN":EMAIL_REGEX_PATTERN,
"TRUESCORE_DONATE_MINIMUM":TRUESCORE_DONATE_MINIMUM, "TRUESCORE_DONATE_MINIMUM":TRUESCORE_DONATE_MINIMUM, "PROGSTACK_ID":PROGSTACK_ID,
"DONATE_LINK":DONATE_LINK, "DONATE_SERVICE":DONATE_SERVICE, "BAN_EVASION_DOMAIN":BAN_EVASION_DOMAIN, "DONATE_LINK":DONATE_LINK, "DONATE_SERVICE":DONATE_SERVICE, "BAN_EVASION_DOMAIN":BAN_EVASION_DOMAIN,
"HOUSE_JOIN_COST":HOUSE_JOIN_COST, "HOUSE_SWITCH_COST":HOUSE_SWITCH_COST, "IMAGE_FORMATS":','.join(IMAGE_FORMATS), "HOUSE_JOIN_COST":HOUSE_JOIN_COST, "HOUSE_SWITCH_COST":HOUSE_SWITCH_COST, "IMAGE_FORMATS":','.join(IMAGE_FORMATS),
"PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "SORTS":SORTS, "PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "SORTS":SORTS,

View File

@ -5,6 +5,8 @@ from files.routes.wrappers import *
from files.__main__ import app, limiter from files.__main__ import app, limiter
from files.routes.routehelpers import get_alt_graph from files.routes.routehelpers import get_alt_graph
from math import floor
@app.get("/votes/<link>") @app.get("/votes/<link>")
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID) @limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@auth_required @auth_required
@ -161,21 +163,24 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
target.realupvotes = get_vote_count(0, True) # first arg is ignored here target.realupvotes = get_vote_count(0, True) # first arg is ignored here
mul = 1 mul = 1
if target.author.progressivestack or (target.author.admin_level and target.author.id not in {AEVANN_ID, CARP_ID}): if target.is_approved == PROGSTACK_ID:
mul = 2 mul = PROGSTACK_MUL
if cls == Submission and target.author.id not in {8768,3402,5214,12719}: else:
if (target.domain.endswith('.win') or 'forum' in target.domain if target.author.progressivestack or (target.author.admin_level and target.author.id not in {AEVANN_ID, CARP_ID}):
or (target.domain in BOOSTED_SITES and not target.url.startswith('/'))
or target.sub in BOOSTED_HOLES):
mul = 2 mul = 2
elif not target.sub and target.body_html: if cls == Submission and target.author.id not in {8768,3402,5214,12719}:
x = target.body_html.count('" target="_blank" rel="nofollow noopener">') if (target.domain.endswith('.win') or 'forum' in target.domain
x += target.body_html.count('<a href="/images/') or (target.domain in BOOSTED_SITES and not target.url.startswith('/'))
target.realupvotes += min(x*2, 20) or target.sub in BOOSTED_HOLES):
mul = 1 + x/10 mul = 2
elif not target.sub and target.body_html:
x = target.body_html.count('" target="_blank" rel="nofollow noopener">')
x += target.body_html.count('<a href="/images/')
target.realupvotes += min(x*2, 20)
mul = 1 + x/10
mul = min(mul, 2) mul = min(mul, 2)
target.realupvotes *= mul target.realupvotes = floor(target.realupvotes * mul)
g.db.add(target) g.db.add(target)
return "", 204 return "", 204

View File

@ -82,6 +82,9 @@
<button type="button" id="mark-{{p.id}}" class="dropdown-item {% if p.over_18 %}d-none{% endif %} list-inline-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/mark_post_nsfw/{{p.id}}','mark-{{p.id}}','unmark-{{p.id}}','d-none')"><i class="fas fa-eye-evil"></i>Mark +18</button> <button type="button" id="mark-{{p.id}}" class="dropdown-item {% if p.over_18 %}d-none{% endif %} list-inline-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/mark_post_nsfw/{{p.id}}','mark-{{p.id}}','unmark-{{p.id}}','d-none')"><i class="fas fa-eye-evil"></i>Mark +18</button>
<button type="button" id="unmark-{{p.id}}" class="dropdown-item {% if not p.over_18 %}d-none{% endif %} list-inline-item text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unmark_post_nsfw/{{p.id}}','mark-{{p.id}}','unmark-{{p.id}}','d-none')"><i class="fas fa-eye-evil"></i>Unmark +18</button> <button type="button" id="unmark-{{p.id}}" class="dropdown-item {% if not p.over_18 %}d-none{% endif %} list-inline-item text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unmark_post_nsfw/{{p.id}}','mark-{{p.id}}','unmark-{{p.id}}','d-none')"><i class="fas fa-eye-evil"></i>Unmark +18</button>
{% endif %} {% endif %}
{% if v.admin_level >= PERMS['PROGSTACK'] %}
<button type="button" id="progstack-{{p.id}}" class="dropdown-item {% if p.is_approved == PROGSTACK_ID %}d-none{% endif %} list-inline-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToast(this,'/admin/progstack/{{p.id}}'"><i class="fas fa-bullhorn"></i>Apply Progressive Stack</button>
{% endif %}
{% if v.admin_level >= PERMS['USER_BAN'] and v.id != p.author_id %} {% if v.admin_level >= PERMS['USER_BAN'] and v.id != p.author_id %}
<button type="button" id="ban-{{p.fullname}}" class="dropdown-item {% if p.author.is_suspended %}d-none{% endif %} list-inline-item text-danger" data-bs-toggle="modal" data-bs-target="#banModal" data-nonce="{{g.nonce}}" data-onclick="banModal('/post/{{p.id}}', '{{p.author_name}}', '{{p.fullname}}','d-none')"><i class="fas fa-user-slash text-danger fa-fw"></i>Ban user</button> <button type="button" id="ban-{{p.fullname}}" class="dropdown-item {% if p.author.is_suspended %}d-none{% endif %} list-inline-item text-danger" data-bs-toggle="modal" data-bs-target="#banModal" data-nonce="{{g.nonce}}" data-onclick="banModal('/post/{{p.id}}', '{{p.author_name}}', '{{p.fullname}}','d-none')"><i class="fas fa-user-slash text-danger fa-fw"></i>Ban user</button>
<button type="button" id="unban-{{p.fullname}}" class="dropdown-item {% if not p.author.is_suspended %}d-none{% endif %} list-inline-item text-success" id="unexile2-user-{{p.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unban_user/{{p.fullname}}','ban-{{p.fullname}}','unban-{{p.fullname}}','d-none')"><i class="fas fa-user-slash"></i>Unban user</button> <button type="button" id="unban-{{p.fullname}}" class="dropdown-item {% if not p.author.is_suspended %}d-none{% endif %} list-inline-item text-success" id="unexile2-user-{{p.id}}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unban_user/{{p.fullname}}','ban-{{p.fullname}}','unban-{{p.fullname}}','d-none')"><i class="fas fa-user-slash"></i>Unban user</button>

View File

@ -36,11 +36,13 @@
<button type="button" id="mark2-{{p.id}}" class="{% if p.over_18 %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/mark_post_nsfw/{{p.id}}','mark2-{{p.id}}','unmark2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="far fa-eye-evil text-center text-danger mr-2"></i>Mark +18</button> <button type="button" id="mark2-{{p.id}}" class="{% if p.over_18 %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/mark_post_nsfw/{{p.id}}','mark2-{{p.id}}','unmark2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="far fa-eye-evil text-center text-danger mr-2"></i>Mark +18</button>
<button type="button" id="unmark2-{{p.id}}" class="{% if not p.over_18 %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unmark_post_nsfw/{{p.id}}','mark2-{{p.id}}','unmark2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="far fa-eye-evil text-center text-success mr-2"></i>Unmark +18</button> <button type="button" id="unmark2-{{p.id}}" class="{% if not p.over_18 %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unmark_post_nsfw/{{p.id}}','mark2-{{p.id}}','unmark2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="far fa-eye-evil text-center text-success mr-2"></i>Unmark +18</button>
{% endif %} {% endif %}
{% if v.admin_level >= PERMS['PROGSTACK'] %}
<button type="button" id="progstack2-{{p.id}}" class="{% if p.is_approved == PROGSTACK_ID %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-danger" data-nonce="{{g.nonce}}" data-onclick="postToast(this,'/admin/progstack/{{p.id}}'" data-bs-dismiss="modal"><i class="fas fa-bullhorn text-center text-danger mr-2"></i>Apply Progressive Stack</button>
{% endif %}
{% if v.id != p.author_id and v.admin_level >= PERMS['USER_BAN'] %} {% if v.id != p.author_id and v.admin_level >= PERMS['USER_BAN'] %}
<button type="button" id="ban2-{{p.fullname}}" data-bs-dismiss="modal" data-bs-toggle="modal" data-bs-target="#banModal" data-nonce="{{g.nonce}}" data-onclick="banModal('/post/{{p.id}}', '{{p.author_name}}', '{{p.fullname}}','d-none')" class="{% if p.author.is_suspended %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left"><i class="fas fa-user-minus mr-2"></i>Ban user</button> <button type="button" id="ban2-{{p.fullname}}" data-bs-dismiss="modal" data-bs-toggle="modal" data-bs-target="#banModal" data-nonce="{{g.nonce}}" data-onclick="banModal('/post/{{p.id}}', '{{p.author_name}}', '{{p.fullname}}','d-none')" class="{% if p.author.is_suspended %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left"><i class="fas fa-user-minus mr-2"></i>Ban user</button>
<button type="button" id="unban2-{{p.fullname}}" class="{% if not p.author.is_suspended %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-success text-left" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unban_user/{{p.fullname}}','ban2-{{p.fullname}}','unban2-{{p.fullname}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-user-minus mr-2"></i>Unban user</button> <button type="button" id="unban2-{{p.fullname}}" class="{% if not p.author.is_suspended %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-success text-left" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unban_user/{{p.fullname}}','ban2-{{p.fullname}}','unban2-{{p.fullname}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-user-minus mr-2"></i>Unban user</button>
{% endif %} {% endif %}
{% if v.id != p.author_id and v.admin_level >= PERMS['USER_AGENDAPOSTER'] %} {% if v.id != p.author_id and v.admin_level >= PERMS['USER_AGENDAPOSTER'] %}
<button type="button" id="chud2-{{p.fullname}}" data-bs-dismiss="modal" data-bs-toggle="modal" data-bs-target="#chudModal" data-nonce="{{g.nonce}}" data-onclick="chudModal('/post/{{p.id}}', '{{p.author_name}}', '{{p.fullname}}','d-none')" class="{% if p.author.agendaposter %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left"><i class="fas fa-face-sleeping mr-2"></i>Chud user</button> <button type="button" id="chud2-{{p.fullname}}" data-bs-dismiss="modal" data-bs-toggle="modal" data-bs-target="#chudModal" data-nonce="{{g.nonce}}" data-onclick="chudModal('/post/{{p.id}}', '{{p.author_name}}', '{{p.fullname}}','d-none')" class="{% if p.author.agendaposter %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left"><i class="fas fa-face-sleeping mr-2"></i>Chud user</button>
<button type="button" id="unchud2-{{p.fullname}}" class="{% if not p.author.agendaposter %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-success text-left" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unagendaposter/{{p.fullname}}','chud2-{{p.fullname}}','unchud2-{{p.fullname}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-face-sleeping mr-2"></i>Unchud user</button> <button type="button" id="unchud2-{{p.fullname}}" class="{% if not p.author.agendaposter %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-success text-left" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unagendaposter/{{p.fullname}}','chud2-{{p.fullname}}','unchud2-{{p.fullname}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-face-sleeping mr-2"></i>Unchud user</button>