forked from rDrama/rDrama
fix /emojis getting cached on browser end
parent
d66e404e00
commit
2a9dfab16a
|
@ -141,7 +141,7 @@ const emojisSearchDictionary = {
|
||||||
|
|
||||||
// get public emojis list
|
// get public emojis list
|
||||||
const emojiRequest = new XMLHttpRequest();
|
const emojiRequest = new XMLHttpRequest();
|
||||||
emojiRequest.open("GET", '/emojis.csv');
|
emojiRequest.open("GET", '/emojis');
|
||||||
emojiRequest.setRequestHeader('xhr', 'xhr');
|
emojiRequest.setRequestHeader('xhr', 'xhr');
|
||||||
emojiRequest.onload = async () => {
|
emojiRequest.onload = async () => {
|
||||||
let emojis = JSON.parse(emojiRequest.response);
|
let emojis = JSON.parse(emojiRequest.response);
|
||||||
|
|
|
@ -75,6 +75,7 @@ LOGGED_IN_CACHE_KEY = f"{SITE}_loggedin"
|
||||||
LOGGED_OUT_CACHE_KEY = f"{SITE}_loggedout"
|
LOGGED_OUT_CACHE_KEY = f"{SITE}_loggedout"
|
||||||
CHAT_ONLINE_CACHE_KEY = f"{SITE}_online"
|
CHAT_ONLINE_CACHE_KEY = f"{SITE}_online"
|
||||||
REDDIT_NOTIFS_CACHE_KEY = "reddit_notifications"
|
REDDIT_NOTIFS_CACHE_KEY = "reddit_notifications"
|
||||||
|
EMOJIS_CACHE_KEY = "emojis"
|
||||||
MARSEYS_CACHE_KEY = "marseys"
|
MARSEYS_CACHE_KEY = "marseys"
|
||||||
|
|
||||||
SESSION_LIFETIME = 60 * 60 * 24 * 365
|
SESSION_LIFETIME = 60 * 60 * 24 * 365
|
||||||
|
|
|
@ -180,10 +180,11 @@ def approve_emoji(v, name):
|
||||||
badge_grant(badge_id=112, user=author)
|
badge_grant(badge_id=112, user=author)
|
||||||
|
|
||||||
|
|
||||||
|
cache.delete(EMOJIS_CACHE_KEY)
|
||||||
if emoji.kind == "Marsey":
|
if emoji.kind == "Marsey":
|
||||||
cache.delete(MARSEYS_CACHE_KEY)
|
cache.delete(MARSEYS_CACHE_KEY)
|
||||||
|
|
||||||
purge_files_in_cache([f"https://{SITE}/e/{emoji.name}/webp", f"https://{SITE}/emojis.csv"])
|
purge_files_in_cache(f"https://{SITE}/e/{emoji.name}/webp")
|
||||||
|
|
||||||
move(f"/asset_submissions/marseys/{name}.webp", f"files/assets/images/emojis/{emoji.name}.webp")
|
move(f"/asset_submissions/marseys/{name}.webp", f"files/assets/images/emojis/{emoji.name}.webp")
|
||||||
|
|
||||||
|
|
|
@ -70,17 +70,25 @@ def marseys(v:User):
|
||||||
break
|
break
|
||||||
return render_template("marseys.html", v=v, marseys=marseys)
|
return render_template("marseys.html", v=v, marseys=marseys)
|
||||||
|
|
||||||
@app.get("/emojis.csv")
|
|
||||||
@limiter.limit(DEFAULT_RATELIMIT)
|
|
||||||
def emoji_list():
|
|
||||||
emojis = []
|
|
||||||
|
|
||||||
|
|
||||||
|
@cache.cached(key_prefix=EMOJIS_CACHE_KEY)
|
||||||
|
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()):
|
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()):
|
||||||
emoji.author = author.username if FEATURES['ASSET_SUBMISSIONS'] else None
|
emoji.author = author.username if FEATURES['ASSET_SUBMISSIONS'] else None
|
||||||
emojis.append(emoji.json())
|
emojis.append(emoji.json())
|
||||||
|
|
||||||
return emojis
|
return emojis
|
||||||
|
|
||||||
|
@app.get("/emojis")
|
||||||
|
@limiter.limit(DEFAULT_RATELIMIT)
|
||||||
|
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
|
||||||
|
@auth_required
|
||||||
|
def emoji_list(v):
|
||||||
|
return get_emojis()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.get('/sidebar')
|
@app.get('/sidebar')
|
||||||
@limiter.limit(DEFAULT_RATELIMIT)
|
@limiter.limit(DEFAULT_RATELIMIT)
|
||||||
@auth_desired
|
@auth_desired
|
||||||
|
|
Loading…
Reference in New Issue