forked from rDrama/rDrama
cache emojis by CF and browsers
parent
430be8e9c4
commit
bfb9456905
|
@ -156,7 +156,8 @@ const emojisSearchDictionary = {
|
|||
function makeEmojisSearchDictionary() {
|
||||
// get public emojis list
|
||||
const headers = new Headers({xhr: "xhr"})
|
||||
return fetch("/emojis.json", {
|
||||
const emoji_num = document.getElementById('emoji_num').value
|
||||
return fetch(`/emojis.csv?x=${emoji_num}`, {
|
||||
headers,
|
||||
})
|
||||
.then(res => res.json())
|
||||
|
@ -190,7 +191,8 @@ function makeEmojisSearchDictionary() {
|
|||
// get public emojis list
|
||||
function fetchEmojis() {
|
||||
const headers = new Headers({xhr: "xhr"})
|
||||
return fetch("/emojis.json", {
|
||||
const emoji_num = document.getElementById('emoji_num').value
|
||||
return fetch(`/emojis.csv?x=${emoji_num}`, {
|
||||
headers,
|
||||
})
|
||||
.then(res => res.json())
|
||||
|
|
|
@ -475,7 +475,7 @@ ERROR_MARSEYS = {
|
|||
500: "marseycarp3",
|
||||
}
|
||||
|
||||
EMOJI_SRCS = ['files/assets/emojis.json']
|
||||
EMOJI_SRCS = ['files/assets/emojis.csv']
|
||||
|
||||
PIN_LIMIT = 3
|
||||
POST_TITLE_LENGTH_LIMIT = 500 # do not make larger than 500 without altering the table
|
||||
|
|
|
@ -54,6 +54,9 @@ def before_request():
|
|||
|
||||
@app.after_request
|
||||
def after_request(response):
|
||||
if request.path == '/emojis.csv':
|
||||
response.cache_control.max_age = 2678400
|
||||
|
||||
user_id = None
|
||||
|
||||
if response.status_code < 400:
|
||||
|
|
|
@ -246,6 +246,8 @@ def approve_emoji(v, name):
|
|||
cache.delete("emojis_False")
|
||||
cache.delete(f"emoji_list_{emoji.kind}_False")
|
||||
|
||||
cache.set("emojis_num", g.db.query(Emojis).count())
|
||||
|
||||
purge_files_in_cloudflare_cache(f"{SITE_FULL_IMAGES}/e/{emoji.name}/webp")
|
||||
|
||||
return {"message": f"'{emoji.name}' approved!"}
|
||||
|
@ -569,6 +571,8 @@ def update_emoji(v):
|
|||
cache.delete("emojis_False")
|
||||
cache.delete(f"emoji_list_{existing.kind}_False")
|
||||
|
||||
cache.set("emojis_num", g.db.query(Emojis).count())
|
||||
|
||||
return {"message": f"'{name}' updated successfully!"}
|
||||
|
||||
@app.get("/admin/update/hats")
|
||||
|
|
|
@ -151,5 +151,5 @@ def inject_constants():
|
|||
"CHUD_PHRASES":CHUD_PHRASES, "hasattr":hasattr, "calc_users":calc_users, "HOLE_INACTIVITY_DELETION":HOLE_INACTIVITY_DELETION, "LIGHT_THEMES":LIGHT_THEMES, "OVER_18_EMOJIS":OVER_18_EMOJIS,
|
||||
"MAX_IMAGE_AUDIO_SIZE_MB":MAX_IMAGE_AUDIO_SIZE_MB, "MAX_IMAGE_AUDIO_SIZE_MB_PATRON":MAX_IMAGE_AUDIO_SIZE_MB_PATRON,
|
||||
"MAX_VIDEO_SIZE_MB":MAX_VIDEO_SIZE_MB, "MAX_VIDEO_SIZE_MB_PATRON":MAX_VIDEO_SIZE_MB_PATRON,
|
||||
"CURSORMARSEY_DEFAULT":CURSORMARSEY_DEFAULT, "SNAPPY_ID":SNAPPY_ID, "get_running_orgy":get_running_orgy, "TRUESCORE_MINIMUM":TRUESCORE_MINIMUM, "bar_position":bar_position, "datetime":datetime, "CSS_LENGTH_LIMIT":CSS_LENGTH_LIMIT
|
||||
"CURSORMARSEY_DEFAULT":CURSORMARSEY_DEFAULT, "SNAPPY_ID":SNAPPY_ID, "get_running_orgy":get_running_orgy, "TRUESCORE_MINIMUM":TRUESCORE_MINIMUM, "bar_position":bar_position, "datetime":datetime, "CSS_LENGTH_LIMIT":CSS_LENGTH_LIMIT, "emoji_num":cache.get("emojis_num") or 0,
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ def get_emojis(nsfw):
|
|||
collected.append(emoji.json())
|
||||
return collected
|
||||
|
||||
@app.get("/emojis.json")
|
||||
@app.get("/emojis.csv")
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
||||
@auth_required
|
||||
|
|
|
@ -70,4 +70,5 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<input hidden id="emoji_num" value="{{emoji_num}}">
|
||||
<script defer src="{{'js/emoji_modal.js' | asset}}"></script>
|
||||
|
|
Loading…
Reference in New Issue