diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py
index 68ddb351c..2d952d170 100644
--- a/files/helpers/config/const.py
+++ b/files/helpers/config/const.py
@@ -75,8 +75,6 @@ LOGGED_IN_CACHE_KEY = f"{SITE}_loggedin"
LOGGED_OUT_CACHE_KEY = f"{SITE}_loggedout"
CHAT_ONLINE_CACHE_KEY = f"{SITE}_online"
REDDIT_NOTIFS_CACHE_KEY = "reddit_notifications"
-EMOJIS_CACHE_KEY = "emojis"
-MARSEYS_CACHE_KEY = "marseys"
SESSION_LIFETIME = 60 * 60 * 24 * 365
@@ -1081,4 +1079,4 @@ else:
STARS = '\n\n★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n\n'
-EMOJIS_KINDS = ("Marsey", "Platy", "Wolf", "Tay", "Donkey Kong", "Marsey Flags", "Marsey Alphabet", "Classic", "Rage", "Wojak", "Misc")
+EMOJI_KINDS = ("Marsey", "Platy", "Wolf", "Tay", "Donkey Kong", "Marsey Flags", "Marsey Alphabet", "Classic", "Rage", "Wojak", "Misc")
diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py
index 1e8d3f210..f49eea562 100644
--- a/files/routes/asset_submissions.py
+++ b/files/routes/asset_submissions.py
@@ -34,7 +34,7 @@ def submit_emojis(v:User):
emoji.author = g.db.query(User.username).filter_by(id=emoji.author_id).one()[0]
emoji.submitter = g.db.query(User.username).filter_by(id=emoji.submitter_id).one()[0]
- return render_template("submit_emojis.html", v=v, emojis=emojis, kinds=EMOJIS_KINDS, msg=get_msg())
+ return render_template("submit_emojis.html", v=v, emojis=emojis, msg=get_msg())
@app.post("/submit/emojis")
@@ -56,9 +56,9 @@ def submit_emoji(v:User):
for emoji in emojis:
emoji.author = g.db.query(User.username).filter_by(id=emoji.author_id).one()[0]
emoji.submitter = g.db.query(User.username).filter_by(id=emoji.submitter_id).one()[0]
- return render_template("submit_emojis.html", v=v, emojis=emojis, error=error, name=name, kind=kind, tags=tags, username=username, kinds=EMOJIS_KINDS), 400
+ return render_template("submit_emojis.html", v=v, emojis=emojis, error=error, name=name, kind=kind, tags=tags, username=username), 400
- if kind not in EMOJIS_KINDS:
+ if kind not in EMOJI_KINDS:
return error("Invalid emoji kind!")
if kind in {"Marsey", "Platy", "Wolf", "Tay"} and not name.startswith(kind.lower()):
@@ -137,7 +137,7 @@ def approve_emoji(v, name):
if not tags_regex.fullmatch(tags):
abort(400, "Invalid tags!")
- if new_kind not in EMOJIS_KINDS:
+ if new_kind not in EMOJI_KINDS:
abort(400, "Invalid kind!")
@@ -180,9 +180,9 @@ def approve_emoji(v, name):
badge_grant(badge_id=112, user=author)
- cache.delete(EMOJIS_CACHE_KEY)
+ cache.delete("emojis")
if emoji.kind == "Marsey":
- cache.delete(MARSEYS_CACHE_KEY)
+ cache.delete("marseys")
purge_files_in_cache(f"https://{SITE}/e/{emoji.name}/webp")
@@ -437,9 +437,10 @@ def update_emoji(v):
file = request.files["image"]
name = request.values.get('name', '').lower().strip()
tags = request.values.get('tags', '').lower().strip()
+ kind = request.values.get('kind', '').strip()
def error(error):
- return render_template("admin/update_assets.html", v=v, error=error, name=name, tags=tags, type="Emoji")
+ return render_template("admin/update_assets.html", v=v, error=error, name=name, tags=tags, kind=kind, type="Emoji")
existing = g.db.get(Emoji, name)
if not existing:
@@ -475,19 +476,31 @@ def update_emoji(v):
if not tags_regex.fullmatch(tags):
abort(400, "Invalid tags!")
existing.tags += f" {tags}"
- g.db.add(existing)
+ updated = True
+
+ if kind and existing.kind != kind and kind != "none":
+ if kind not in EMOJI_KINDS:
+ abort(400, "Invalid kind!")
+ existing.kind = kind
updated = True
if not updated:
return error("You need to actually update something!")
+ g.db.add(existing)
+
ma = ModAction(
kind="update_emoji",
user_id=v.id,
_note=f''
)
g.db.add(ma)
- return render_template("admin/update_assets.html", v=v, msg=f"'{name}' updated successfully!", name=name, tags=tags, type="Emoji")
+
+ cache.delete("emojis")
+ if existing.kind == "Marsey":
+ cache.delete("marseys")
+
+ return render_template("admin/update_assets.html", v=v, msg=f"'{name}' updated successfully!", name=name, tags=tags, kind=kind, type="Emoji")
@app.get("/admin/update/hats")
@limiter.limit(DEFAULT_RATELIMIT)
diff --git a/files/routes/jinja2.py b/files/routes/jinja2.py
index 36b923f7d..242e6ec28 100644
--- a/files/routes/jinja2.py
+++ b/files/routes/jinja2.py
@@ -144,5 +144,6 @@ def inject_constants():
"DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "IS_FISTMAS":IS_FISTMAS, "get_alt_graph":get_alt_graph, "current_registered_users":current_registered_users,
"git_head":git_head, "max_days":max_days,
"BIO_FRIENDS_ENEMIES_LENGTH_LIMIT":BIO_FRIENDS_ENEMIES_LENGTH_LIMIT,
- "IMMUNE_TO_AWARDS": IMMUNE_TO_AWARDS, "SITE_FULL_IMAGES": SITE_FULL_IMAGES
+ "IMMUNE_TO_AWARDS": IMMUNE_TO_AWARDS, "SITE_FULL_IMAGES": SITE_FULL_IMAGES,
+ "EMOJI_KINDS": EMOJI_KINDS,
}
diff --git a/files/routes/static.py b/files/routes/static.py
index 852b046f5..15fa5e9c2 100644
--- a/files/routes/static.py
+++ b/files/routes/static.py
@@ -41,7 +41,7 @@ def reddit_post(subreddit, v, path):
return redirect(f'https://{reddit}/{post_id}')
-@cache.cached(key_prefix=MARSEYS_CACHE_KEY)
+@cache.cached(key_prefix="marseys")
def get_marseys(db:scoped_session):
if not FEATURES['MARSEYS']: return []
marseys = []
@@ -72,7 +72,7 @@ def marseys(v:User):
-@cache.cached(key_prefix=EMOJIS_CACHE_KEY)
+@cache.cached(key_prefix="emojis")
def get_emojis():
emojis = []
for emoji, author in g.db.query(Emoji, User).join(User, Emoji.author_id == User.id).filter(Emoji.submitter_id == None).order_by(Emoji.count.desc()):
diff --git a/files/templates/admin/update_assets.html b/files/templates/admin/update_assets.html
index 994df3c08..45637e27a 100644
--- a/files/templates/admin/update_assets.html
+++ b/files/templates/admin/update_assets.html
@@ -23,6 +23,22 @@
+ {% if type == "Emoji" %}
+
+