enforce emoji naming scheme

pull/142/head
Aevann 2023-03-18 17:21:20 +02:00
parent d6e9487a36
commit 99ef7575ad
1 changed files with 9 additions and 3 deletions

View File

@ -49,12 +49,18 @@ def submit_emoji(v:User):
username = request.values.get('author', '').lower().strip()
kind = request.values.get('kind', '').strip()
if kind not in EMOJIS_KINDS:
abort(400, "Invalid emoji kind!")
def error(error):
return redirect(f"/submit/emojis?error={error}")
if kind not in EMOJIS_KINDS:
return error("Invalid emoji kind!")
if kind in {"Marsey", "Platy", "Wolf", "Tay"} and not name.startswith(kind.lower()):
return error(f'The name of this emoji should start with the word "{kind.lower()}"')
if kind == "Marsey Flags" and not name.startswith("marseyflag"):
return error('The name of this emoji should start with the word "marseyflag"')
if g.is_tor:
return error("Image uploads are not allowed through TOR!")