mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2025-07-04 20:25:25 +02:00
Remove keyvalue properties in favor of redis
This commit is contained in:
@ -2,8 +2,7 @@ from config import config
|
||||
import json
|
||||
from requests_oauthlib import OAuth2Session
|
||||
from flask import session, abort, url_for
|
||||
from titanembeds.database import get_keyvalproperty, set_keyvalproperty
|
||||
from titanembeds.utils import make_user_cache_key
|
||||
from titanembeds.utils import redis_store, make_user_cache_key
|
||||
|
||||
authorize_url = "https://discordapp.com/api/oauth2/authorize"
|
||||
token_url = "https://discordapp.com/api/oauth2/token"
|
||||
@ -45,14 +44,14 @@ def user_has_permission(permission, index):
|
||||
return bool((int(permission) >> index) & 1)
|
||||
|
||||
def get_user_guilds():
|
||||
cache = get_keyvalproperty("OAUTH/USERGUILDS/"+str(make_user_cache_key()))
|
||||
cache = redis_store.get("OAUTH/USERGUILDS/"+str(make_user_cache_key()))
|
||||
if cache:
|
||||
return cache
|
||||
return cache.decode("utf-8")
|
||||
req = discordrest_from_user("/users/@me/guilds")
|
||||
if req.status_code != 200:
|
||||
abort(req.status_code)
|
||||
req = json.dumps(req.json())
|
||||
set_keyvalproperty("OAUTH/USERGUILDS/"+str(make_user_cache_key()), req, 250)
|
||||
redis_store.set("OAUTH/USERGUILDS/"+str(make_user_cache_key()), req, 250)
|
||||
return req
|
||||
|
||||
def get_user_managed_servers():
|
||||
|
Reference in New Issue
Block a user