This commit is contained in:
parent
93c1727be3
commit
9d1a4e90c9
|
@ -52,7 +52,8 @@ async def load_messages(
|
|||
@login_required
|
||||
async def load_chats(_, info, limit: int = 50, offset: int = 0) -> Dict[str, Union[List[Dict[str, Any]], None]]:
|
||||
"""load :limit chats of current user with :offset"""
|
||||
author_id = info.context["author_id"]
|
||||
author_id = info.context.get("author_id")
|
||||
if author_id:
|
||||
cids = await redis.execute("SMEMBERS", f"chats_by_author/{author_id}")
|
||||
chats = []
|
||||
if cids:
|
||||
|
|
|
@ -49,7 +49,7 @@ async def check_auth(req) -> str | None:
|
|||
print(f"[services.auth] {e}")
|
||||
|
||||
if not user_id:
|
||||
raise HTTPException(status_code=401,detail="Unauthorized")
|
||||
raise HTTPException(status_code=401, detail="Unauthorized")
|
||||
|
||||
|
||||
def login_required(f):
|
||||
|
@ -57,7 +57,9 @@ def login_required(f):
|
|||
async def decorated_function(*args, **kwargs):
|
||||
info = args[1]
|
||||
context = info.context
|
||||
print("[login_required] context: " + str(context))
|
||||
req = context.get("request")
|
||||
print("[login_required] request: " + str(req))
|
||||
user_id = await check_auth(req)
|
||||
if user_id:
|
||||
context["user_id"] = user_id
|
||||
|
|
|
@ -23,7 +23,13 @@ async def get_all_authors(limit: int = 50, offset: int = 0) -> List[ChatMember]:
|
|||
query_name = "load_authors_all"
|
||||
|
||||
gql = {
|
||||
"query": "query { " + query_name + "(limit: " + str(limit) + ", offset: " + str(offset) +") { id slug pic name } }",
|
||||
"query": "query { "
|
||||
+ query_name
|
||||
+ "(limit: "
|
||||
+ str(limit)
|
||||
+ ", offset: "
|
||||
+ str(offset)
|
||||
+ ") { id slug pic name } }",
|
||||
"variables": None,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user