some-fixes-graphql
This commit is contained in:
parent
f6ef50f878
commit
405dbb49cf
|
@ -51,7 +51,7 @@ async def load_chats(_, info, limit: int = 50, offset: int = 0):
|
||||||
members_online = (await redis.execute("SMEMBERS", "authors-online")) or []
|
members_online = (await redis.execute("SMEMBERS", "authors-online")) or []
|
||||||
chats = []
|
chats = []
|
||||||
if len(cids) == 0:
|
if len(cids) == 0:
|
||||||
print("[resolvers.load] no chats for user {}, create one with Discours (id=2)")
|
print(f"[resolvers.load] no chats for user with id={author_id}, create one with Discours (id=2)")
|
||||||
r = await create_chat(None, info, members=[2]) # member with id = 1 is discours
|
r = await create_chat(None, info, members=[2]) # member with id = 1 is discours
|
||||||
cids.append(r["chat"]["id"])
|
cids.append(r["chat"]["id"])
|
||||||
for cid in cids:
|
for cid in cids:
|
||||||
|
|
|
@ -32,13 +32,17 @@ async def check_auth(req):
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
return False, None
|
return False, None
|
||||||
r = response.json()
|
r = response.json()
|
||||||
user_id = (
|
try:
|
||||||
r.get("data", {}).get(query_name, {}).get("user", {}).get("id", None)
|
user_id = (
|
||||||
if INTERNAL_AUTH_SERVER
|
r.get("data", {}).get(query_name, {}).get("user", {}).get("id", None)
|
||||||
else r.get("data", {}).get(query_name, {}).get("user", {}).get("id", None)
|
if INTERNAL_AUTH_SERVER
|
||||||
)
|
else r.get("data", {}).get(query_name, {}).get("user", {}).get("id", None)
|
||||||
is_authenticated = user_id is not None
|
)
|
||||||
return is_authenticated, user_id
|
is_authenticated = user_id is not None
|
||||||
|
return is_authenticated, user_id
|
||||||
|
except Exception as e:
|
||||||
|
print(f"response contains no proper data: {r}")
|
||||||
|
return False, None
|
||||||
|
|
||||||
|
|
||||||
def login_required(f):
|
def login_required(f):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user