Remove unused ADMINISTRATORS content upload posts.

The ADMINISTRATORS list contained hardcoded post IDs (in the 30000s)
intended to be used for uploading graphical assets onto a production
instance of the site. This functionality is not needed here, and the
special logic to bypass awards when commenting on those posts was
largely removed in 9d4195a89f.
This commit is contained in:
TLSM 2022-11-07 03:09:24 -05:00 committed by Ben Rog-Wilhelm
parent 3f360bb457
commit 8949b57609
3 changed files with 13 additions and 40 deletions

View file

@ -255,8 +255,6 @@ utm_regex2 = re.compile('[?&]utm_[a-z]+=[a-z0-9_]+', flags=re.A)
YOUTUBE_KEY = environ.get("YOUTUBE_KEY", "").strip() YOUTUBE_KEY = environ.get("YOUTUBE_KEY", "").strip()
ADMINISTRATORS = (37696, 37697, 37749, 37833, 37838)
proxies = {"http":"http://127.0.0.1:18080","https":"http://127.0.0.1:18080"} proxies = {"http":"http://127.0.0.1:18080","https":"http://127.0.0.1:18080"}
approved_embed_hosts = [ approved_embed_hosts = [

View file

@ -64,5 +64,4 @@ def inject_constants():
"config":app.config.get, "config":app.config.get,
"DEFAULT_COLOR":DEFAULT_COLOR, "DEFAULT_COLOR":DEFAULT_COLOR,
"COLORS":COLORS, "COLORS":COLORS,
"ADMINISTRATORS":ADMINISTRATORS
} }

View file

@ -179,35 +179,9 @@ def api_comment(v):
oldname = f'/images/{time.time()}'.replace('.','') + '.webp' oldname = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(oldname) file.save(oldname)
image = process_image(oldname) image = process_image(oldname)
if image == "": return {"error":"Image upload failed"} if image == "":
if v.admin_level > 2 and level == 1: return {"error":"Image upload failed"}
if parent_post.id == 37696:
pass
# filename = 'files/assets/images/rDrama/sidebar/' + str(len(listdir('files/assets/images/rDrama/sidebar'))+1) + '.webp'
# copyfile(oldname, filename)
# process_image(filename, 400)
elif parent_post.id == 37697:
pass
# filename = 'files/assets/images/rDrama/banners/' + str(len(listdir('files/assets/images/rDrama/banners'))+1) + '.webp'
# copyfile(oldname, filename)
# process_image(filename)
elif parent_post.id == 37833:
try:
badge_def = loads(body)
name = badge_def["name"]
existing = g.db.query(BadgeDef).filter_by(name=name).one_or_none()
if existing: return {"error": "A badge with this name already exists!"}, 403
badge = BadgeDef(name=name, description=badge_def["description"])
g.db.add(badge)
g.db.flush()
filename = f'files/assets/images/badges/{badge.id}.webp'
copyfile(oldname, filename)
process_image(filename, 200)
requests.post(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/purge_cache', headers=CF_HEADERS, data={'files': [f"https://{request.host}/assets/images/badges/{badge.id}.webp"]}, timeout=5)
except Exception as e:
return {"error": str(e)}, 400
if app.config['MULTIMEDIA_EMBEDDING_ENABLED']: if app.config['MULTIMEDIA_EMBEDDING_ENABLED']:
body += f"\n\n![]({image})" body += f"\n\n![]({image})"
else: else:
@ -231,21 +205,23 @@ def api_comment(v):
body_html = sanitize(body, comment=True) body_html = sanitize(body, comment=True)
if parent_post.id not in ADMINISTRATORS: existing = g.db.query(Comment.id).filter(
existing = g.db.query(Comment.id).filter(Comment.author_id == v.id, Comment.author_id == v.id,
Comment.deleted_utc == 0, Comment.deleted_utc == 0,
Comment.parent_comment_id == parent_comment_id, Comment.parent_comment_id == parent_comment_id,
Comment.parent_submission == parent_post.id, Comment.parent_submission == parent_post.id,
Comment.body_html == body_html Comment.body_html == body_html
).one_or_none() ).one_or_none()
if existing: return {"error": f"You already made that comment: /comment/{existing.id}"}, 409
if existing:
return {"error": f"You already made that comment: /comment/{existing.id}"}, 409
if parent.author.any_block_exists(v) and v.admin_level < 2: if parent.author.any_block_exists(v) and v.admin_level < 2:
return {"error": "You can't reply to users who have blocked you, or users you have blocked."}, 403 return {"error": "You can't reply to users who have blocked you, or users you have blocked."}, 403
is_bot = bool(request.headers.get("Authorization")) is_bot = bool(request.headers.get("Authorization"))
if parent_post.id not in ADMINISTRATORS and not is_bot and len(body) > 10: if not is_bot and len(body) > 10:
now = int(time.time()) now = int(time.time())
cutoff = now - 60 * 60 * 24 cutoff = now - 60 * 60 * 24