stop separating online counter by chat type

pull/90/head
Aevann 2023-01-22 02:11:01 +02:00
parent 57fdc74a43
commit 3e5599cd96
1 changed files with 8 additions and 11 deletions

View File

@ -24,11 +24,8 @@ typing = {
f'{SITE_FULL}/chat': [], f'{SITE_FULL}/chat': [],
f'{SITE_FULL}/admin/chat': [] f'{SITE_FULL}/admin/chat': []
} }
online = { online = []
f'{SITE_FULL}/chat': [], cache.set(CHAT_ONLINE_CACHE_KEY, len(online), timeout=0)
f'{SITE_FULL}/admin/chat': []
}
cache.set(CHAT_ONLINE_CACHE_KEY, len(online[f'{SITE_FULL}/chat']), timeout=0)
muted = cache.get(f'muted') or { muted = cache.get(f'muted') or {
f'{SITE_FULL}/chat': {}, f'{SITE_FULL}/chat': {},
f'{SITE_FULL}/admin/chat': {} f'{SITE_FULL}/admin/chat': {}
@ -125,9 +122,9 @@ def speak(data, v):
return '', 204 return '', 204
def refresh_online(): def refresh_online():
emit("online", online[request.referrer], room=request.referrer, broadcast=True) emit("online", online, broadcast=True)
if request.referrer == f'{SITE_FULL}/chat': if request.referrer == f'{SITE_FULL}/chat':
cache.set(CHAT_ONLINE_CACHE_KEY, len(online[request.referrer]), timeout=0) cache.set(CHAT_ONLINE_CACHE_KEY, len(online), timeout=0)
@socketio.on('connect') @socketio.on('connect')
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID) @limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@ -135,8 +132,8 @@ def refresh_online():
def connect(v): def connect(v):
join_room(request.referrer) join_room(request.referrer)
if v.username not in online[request.referrer]: if v.username not in online:
online[request.referrer].append(v.username) online.append(v.username)
refresh_online() refresh_online()
emit('catchup', messages[request.referrer], room=request.referrer) emit('catchup', messages[request.referrer], room=request.referrer)
@ -147,8 +144,8 @@ def connect(v):
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID) @limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@admin_level_required(PERMS['CHAT']) @admin_level_required(PERMS['CHAT'])
def disconnect(v): def disconnect(v):
if v.username in online[request.referrer]: if v.username in online:
online[request.referrer].remove(v.username) online.remove(v.username)
refresh_online() refresh_online()
if v.username in typing[request.referrer]: if v.username in typing[request.referrer]: