forked from rDrama/rDrama
chat: fix 500 on some... weird... state... i think?
cache: get out of jinja templates chat: threshold is now a constmaster
parent
0dd7809b49
commit
5056f09380
|
@ -62,6 +62,7 @@ IS_LOCALHOST = SITE == "localhost" or SITE == "127.0.0.1" or SITE.startswith("19
|
|||
if IS_LOCALHOST: SITE_FULL = 'http://' + SITE
|
||||
else: SITE_FULL = 'https://' + SITE
|
||||
|
||||
CHAT_ONLINE_CACHE_KEY = f'{SITE}_online'
|
||||
REDDIT_NOTIFS_CACHE_KEY = "reddit_notifications"
|
||||
MARSEYS_CACHE_KEY = "marseys"
|
||||
EMOJIS_CACHE_KEY = "emojis"
|
||||
|
@ -397,6 +398,7 @@ COSMETIC_AWARD_COIN_AWARD_PCT = 0.10
|
|||
TRUESCORE_CHAT_MINIMUM = 0
|
||||
TRUESCORE_DONATE_MINIMUM = 100
|
||||
TRUESCORE_GHOST_MINIMUM = 0
|
||||
CHAT_DISPLAY_USER_COUNT_MINIMUM = 0
|
||||
|
||||
LOGGEDIN_ACTIVE_TIME = 15 * 60
|
||||
PFP_DEFAULT_MARSEY = True
|
||||
|
@ -507,6 +509,7 @@ if SITE == 'rdrama.net':
|
|||
CHAT_LENGTH_LIMIT = 200
|
||||
TRUESCORE_CHAT_MINIMUM = 10
|
||||
TRUESCORE_GHOST_MINIMUM = 10
|
||||
CHAT_DISPLAY_USER_COUNT_MINIMUM = 10
|
||||
NEW_USER_HAT_AGE = 7 * 86400
|
||||
|
||||
HOLE_COST = 50000
|
||||
|
@ -1633,8 +1636,6 @@ tiers={
|
|||
has_sidebar = path.exists(f'files/templates/sidebar_{SITE_NAME}.html')
|
||||
has_logo = path.exists(f'files/assets/images/{SITE_NAME}/logo.webp')
|
||||
|
||||
ONLINE_STR = f'{SITE}_online'
|
||||
|
||||
forced_hats = {
|
||||
"rehab": ("Roulette", "I'm a recovering ludomaniac!"),
|
||||
"progressivestack": ("Attention Whore", "I won the oppression olympics!"),
|
||||
|
|
|
@ -96,9 +96,9 @@ def merge(v, id1, id2):
|
|||
g.db.add(user1)
|
||||
g.db.add(user2)
|
||||
|
||||
online = cache.get(ONLINE_STR)
|
||||
online = cache.get(CHAT_ONLINE_CACHE_KEY)
|
||||
cache.clear()
|
||||
cache.set(ONLINE_STR, online)
|
||||
cache.set(CHAT_ONLINE_CACHE_KEY, online)
|
||||
|
||||
return redirect(user1.url)
|
||||
|
||||
|
@ -146,9 +146,9 @@ def merge_all(v, id):
|
|||
|
||||
g.db.add(user)
|
||||
|
||||
online = cache.get(ONLINE_STR)
|
||||
online = cache.get(CHAT_ONLINE_CACHE_KEY)
|
||||
cache.clear()
|
||||
cache.set(ONLINE_STR, online)
|
||||
cache.set(CHAT_ONLINE_CACHE_KEY, online)
|
||||
|
||||
return redirect(user.url)
|
||||
|
||||
|
@ -480,9 +480,9 @@ def clear_cloudflare_cache(v):
|
|||
@app.post("/admin/clear_internal_cache")
|
||||
@admin_level_required(PERMS['SITE_CACHE_DUMP_INTERNAL'])
|
||||
def admin_clear_internal_cache(v):
|
||||
online = cache.get(ONLINE_STR)
|
||||
online = cache.get(CHAT_ONLINE_CACHE_KEY)
|
||||
cache.clear()
|
||||
cache.set(ONLINE_STR, online)
|
||||
cache.set(CHAT_ONLINE_CACHE_KEY, online)
|
||||
ma = ModAction(
|
||||
kind="clear_internal_cache",
|
||||
user_id=v.id
|
||||
|
|
|
@ -29,7 +29,7 @@ else:
|
|||
|
||||
typing = []
|
||||
online = []
|
||||
cache.set(ONLINE_STR, len(online), timeout=0)
|
||||
cache.set(CHAT_ONLINE_CACHE_KEY, len(online), timeout=0)
|
||||
muted = cache.get(f'{SITE}_muted') or {}
|
||||
messages = cache.get(f'{SITE}_chat') or []
|
||||
total = cache.get(f'{SITE}_total') or 0
|
||||
|
@ -113,7 +113,7 @@ def connect(v):
|
|||
if v.username not in online:
|
||||
online.append(v.username)
|
||||
emit("online", online, broadcast=True)
|
||||
cache.set(ONLINE_STR, len(online), timeout=0)
|
||||
cache.set(CHAT_ONLINE_CACHE_KEY, len(online), timeout=0)
|
||||
|
||||
if not socket_ids_to_user_ids.get(request.sid):
|
||||
socket_ids_to_user_ids[request.sid] = v.id
|
||||
|
@ -130,7 +130,7 @@ def disconnect(v):
|
|||
if v.username in online:
|
||||
online.remove(v.username)
|
||||
emit("online", online, broadcast=True)
|
||||
cache.set(ONLINE_STR, len(online), timeout=0)
|
||||
cache.set(CHAT_ONLINE_CACHE_KEY, len(online), timeout=0)
|
||||
|
||||
if v.username in typing: typing.remove(v.username)
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ def inject_constants():
|
|||
"HOLE_NAME":HOLE_NAME, "HOLE_STYLE_FLAIR":HOLE_STYLE_FLAIR, "HOLE_REQUIRED":HOLE_REQUIRED,
|
||||
"GUMROAD_LINK":GUMROAD_LINK, "DEFAULT_THEME":DEFAULT_THEME, "DESCRIPTION":DESCRIPTION,
|
||||
"has_sidebar":has_sidebar, "has_logo":has_logo,
|
||||
"FP":FP, "cache":cache, "ONLINE_STR":ONLINE_STR, "patron":patron, "DUES":DUES,
|
||||
"FP":FP, "CHAT_DISPLAY_USER_COUNT_MINIMUM":CHAT_DISPLAY_USER_COUNT_MINIMUM, "patron":patron, "DUES":DUES,
|
||||
"SIDEBAR_THREAD":SIDEBAR_THREAD, "BANNER_THREAD":BANNER_THREAD,
|
||||
"BADGE_THREAD":BADGE_THREAD, "SNAPPY_THREAD":SNAPPY_THREAD,
|
||||
"KOFI_TOKEN":KOFI_TOKEN, "KOFI_LINK":KOFI_LINK,
|
||||
|
|
|
@ -21,6 +21,7 @@ def calc_users(v):
|
|||
if g.is_api_or_xhr:
|
||||
g.loggedin_counter = 0
|
||||
g.loggedout_counter = 0
|
||||
g.loggedin_chat = 0
|
||||
return ''
|
||||
loggedin = cache.get(f'{SITE}_loggedin') or {}
|
||||
loggedout = cache.get(f'{SITE}_loggedout') or {}
|
||||
|
@ -42,6 +43,7 @@ def calc_users(v):
|
|||
|
||||
g.loggedin_counter = len(loggedin)
|
||||
g.loggedout_counter = len(loggedout)
|
||||
g.loggedin_chat = cache.get(CHAT_ONLINE_CACHE_KEY)
|
||||
return ''
|
||||
|
||||
def get_logged_in_user():
|
||||
|
|
|
@ -176,7 +176,7 @@
|
|||
<a class="nav-link position-relative" href="/chat">
|
||||
<i class="fas fa-messages" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Chat"></i>
|
||||
<b class="text-lg" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Users in chat right now">
|
||||
{{cache.get(ONLINE_STR)}}
|
||||
{{g.loggedin_chat}}
|
||||
</b>
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<div class="container d-inline-flex d-lg-none">
|
||||
|
||||
<div class="row fixed-bottom bg-white border-top p-2" id="mobile-bottom-navigation-bar"
|
||||
style="z-index: 1000; bottom: 0px; transition: bottom cubic-bezier(0, 0, 0.2, 1) 220ms;">
|
||||
|
||||
|
@ -47,11 +46,11 @@
|
|||
</a>
|
||||
</button>
|
||||
{% if v %}
|
||||
{% if FEATURES['CHAT'] and (SITE_NAME != 'rDrama' or cache.get(ONLINE_STR) >= 10) -%}
|
||||
{% if FEATURES['CHAT'] and g.loggedin_chat >= CHAT_DISPLAY_USER_COUNT_MINIMUM -%}
|
||||
<button type="button" class="col px-0 btn btn-dead m-0 pt-0" style="background: None !important; border: None;">
|
||||
<a href="/chat" class="text-decoration-none">
|
||||
<div class="text-center {% if request.path=='/chat' %}text-primary{% else %}text-muted{% endif %}">
|
||||
<b class="text-lg" style="padding-top:10px" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Users in chat right now">{{cache.get(ONLINE_STR)}}</b>
|
||||
<b class="text-lg" style="padding-top:10px" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Users in chat right now">{{g.loggedin_chat}}</b>
|
||||
<div class="text-small">Chat</div>
|
||||
</div>
|
||||
</a>
|
||||
|
|
Loading…
Reference in New Issue