some-more-fixes

This commit is contained in:
Untone 2023-10-11 22:47:25 +03:00
parent 8c87457a09
commit 85fc48b3c8
2 changed files with 9 additions and 5 deletions

View File

@ -44,7 +44,9 @@ async def update_chat(_, info, chat_new):
@mutation.field("createChat")
@login_required
async def create_chat(_, info, title="", members=[]):
async def create_chat(_, info, title="", members=None):
if members is None:
members = []
chat = None
author_id = info.context["author_id"]
print("create_chat members: %r" % members)

View File

@ -26,7 +26,7 @@ async def get_author(author_id):
return None
async def get_network(author_id, limit=50, offset=0):
async def get_network(author_id, limit=50, offset=0) -> list:
gql = {
"query": "query LoadAuthors { authorFollowings(author_id: %s, limit: %s, offset: %s) { id slug userpic name } }"
% (author_id, limit, offset),
@ -40,7 +40,7 @@ async def get_network(author_id, limit=50, offset=0):
async with AsyncClient() as client:
response = await client.post(API_BASE, headers=headers, data=json.dumps(gql))
if response.status_code != 200:
return False, None
return []
r = response.json()
followings = r.get("data", {}).get("authorFollowings", [])
more_amount = limit - len(followings)
@ -49,7 +49,9 @@ async def get_network(author_id, limit=50, offset=0):
except Exception as e:
print(e)
return followings + followers
followings.extend(followers)
return followings
async def get_followers(author_id, amount):
@ -64,7 +66,7 @@ async def get_followers(author_id, amount):
async with AsyncClient() as client:
response = await client.post(API_BASE, headers=headers, data=json.dumps(gql))
if response.status_code != 200:
return False, None
return []
r = response.json()
followers = r.get("data", {}).get("authorFollowers", [])
except Exception as e: