diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 4a94e09..b965dbf 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ - auth logix synced with core - added httpx - aiohttp and requests removed +- core adapter loads data from redis now [0.3.1] - glitchtip connect diff --git a/services/auth.py b/services/auth.py index 92596a0..4974587 100644 --- a/services/auth.py +++ b/services/auth.py @@ -63,7 +63,7 @@ def login_required(f): user_id, user_roles = await check_auth(req) if user_id and isinstance(user_id, str): context["user_id"] = user_id.strip() - author = get_author_by_user(user_id) + author = await get_author_by_user(user_id) if author and "id" in author: context["author_id"] = author["id"] return await f(*args, **kwargs) @@ -80,7 +80,7 @@ def auth_request(f): user_id, user_roles = await check_auth(req) if user_id and isinstance(user_id, str): user_id = user_id.strip() - author = get_author_by_user(user_id) + author = await get_author_by_user(user_id) if author and "id" in author: req["author_id"] = author["id"] return await f(*args, **kwargs) diff --git a/services/core.py b/services/core.py index d1e9cef..f6ad00f 100644 --- a/services/core.py +++ b/services/core.py @@ -10,33 +10,33 @@ from services.rediscache import redis logger.setLevel(logging.DEBUG) -def get_all_authors(): +async def get_all_authors(): authors = [] redis_key = "user:*" - result = redis.execute("GET", redis_key) + result = await redis.execute("GET", redis_key) if isinstance(result, str): authors = json.loads(result) return authors -def get_author_by_user(user: str): +async def get_author_by_user(user: str): author = None redis_key = f"user:{user}" - result = redis.execute("GET", redis_key) + result = await redis.execute("GET", redis_key) if isinstance(result, str): author = json.loads(result) return author -def get_author_followed(author_id: int): +async def get_author_followed(author_id: int): authors = [] redis_key = f"author:{author_id}:follows-authors" - result = redis.execute("GET", redis_key) + result = await redis.execute("GET", redis_key) if isinstance(result, str): authors = json.loads(result)