forked from MarseyWorld/MarseyWorld
make april fool switches permanent during the event
parent
bee874a3d1
commit
d16a15d00b
|
@ -83,8 +83,6 @@ if "cron" not in argv:
|
||||||
cache = Cache(app)
|
cache = Cache(app)
|
||||||
Compress(app)
|
Compress(app)
|
||||||
|
|
||||||
redis_instance = redis.Redis.from_url(app.config["CACHE_REDIS_URL"])
|
|
||||||
|
|
||||||
from files.routes.allroutes import *
|
from files.routes.allroutes import *
|
||||||
|
|
||||||
if "load_chat" in argv:
|
if "load_chat" in argv:
|
||||||
|
|
|
@ -1434,12 +1434,18 @@ class User(Base):
|
||||||
or (has_request_context() and request.path in {'/notifications/modmail', '/notifications/messages'}):
|
or (has_request_context() and request.path in {'/notifications/modmail', '/notifications/messages'}):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
uid = redis_instance.get(f'{self.id}-switched')
|
||||||
|
if uid: return g.db.get(User, uid)
|
||||||
|
|
||||||
three_days = time.time() - 259200
|
three_days = time.time() - 259200
|
||||||
return g.db.query(User).filter(
|
uid = g.db.query(User.id).filter(
|
||||||
User.truescore < self.truescore,
|
User.truescore < self.truescore,
|
||||||
User.last_active > three_days,
|
User.last_active > three_days,
|
||||||
not_(User.username.like('deleted~%')),
|
not_(User.username.like('deleted~%')),
|
||||||
).order_by(User.truescore.desc()).first() or self
|
).order_by(User.truescore.desc()).first()
|
||||||
|
uid = uid[0] if uid else self.id
|
||||||
|
redis_instance.set(f'{self.id}-switched', uid)
|
||||||
|
return g.db.get(User, uid)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
|
|
|
@ -3,6 +3,7 @@ from os import environ, path
|
||||||
|
|
||||||
import tldextract
|
import tldextract
|
||||||
import datetime
|
import datetime
|
||||||
|
import redis
|
||||||
|
|
||||||
DEFAULT_TIME_FILTER = "all"
|
DEFAULT_TIME_FILTER = "all"
|
||||||
DEFAULT_THEME = "midnight"
|
DEFAULT_THEME = "midnight"
|
||||||
|
@ -1465,3 +1466,5 @@ else:
|
||||||
from flask import abort
|
from flask import abort
|
||||||
def stop(code, message=None):
|
def stop(code, message=None):
|
||||||
abort(code, message)
|
abort(code, message)
|
||||||
|
|
||||||
|
redis_instance = redis.Redis.from_url(environ.get("REDIS_URL").strip())
|
|
@ -5,7 +5,7 @@ from files.helpers.config.const import *
|
||||||
from files.helpers.settings import get_setting
|
from files.helpers.settings import get_setting
|
||||||
from files.helpers.cloudflare import CLOUDFLARE_AVAILABLE
|
from files.helpers.cloudflare import CLOUDFLARE_AVAILABLE
|
||||||
from files.routes.wrappers import *
|
from files.routes.wrappers import *
|
||||||
from files.__main__ import app, limiter, get_IP, redis_instance
|
from files.__main__ import app, limiter, get_IP
|
||||||
|
|
||||||
if FEATURES['IP_LOGGING']:
|
if FEATURES['IP_LOGGING']:
|
||||||
from files.classes.ip_logs import *
|
from files.classes.ip_logs import *
|
||||||
|
|
Loading…
Reference in New Issue