core-service-connector-fix

This commit is contained in:
Untone 2023-10-12 15:15:06 +03:00
parent 85fc48b3c8
commit f6ef50f878
3 changed files with 16 additions and 11 deletions

View File

@ -51,7 +51,8 @@ async def load_chats(_, info, limit: int = 50, offset: int = 0):
members_online = (await redis.execute("SMEMBERS", "authors-online")) or []
chats = []
if len(cids) == 0:
r = await create_chat(None, info, members=[1]) # member with id = 1 is discours
print("[resolvers.load] no chats for user {}, create one with Discours (id=2)")
r = await create_chat(None, info, members=[2]) # member with id = 1 is discours
cids.append(r["chat"]["id"])
for cid in cids:
c = await redis.execute("GET", f"chats/{cid}")

View File

@ -9,10 +9,9 @@ headers = {"Content-Type": "application/json"}
async def get_author(author_id):
gql = {
"query": "query GetAuthor { getAuthor(author_id: %s) { id slug userpic name lastSeen } }"
% author_id,
"query": "query GetAuthor { getAuthor(author_id: Int!) { id slug userpic name lastSeen } }",
"operation": "GetAuthor",
"variables": None
"variables": { "author_id" : author_id }
}
try:
async with AsyncClient() as client:
@ -28,10 +27,13 @@ async def get_author(author_id):
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),
"query": "query LoadAuthors { authorFollowings(author_id: Int!, limit: Int, offset: Int) { id slug userpic name } }",
"operation": "LoadAuthors",
"variables": None
"variables": {
"author_id": author_id,
"limit": limit,
"offset": offset
}
}
followings = []
@ -56,10 +58,12 @@ async def get_network(author_id, limit=50, offset=0) -> list:
async def get_followers(author_id, amount):
gql = {
"query": "query LoadAuthors { authorFollowers(author_id: %s, limit: %s) { id slug userpic name } }"
% (author_id, amount),
"query": "query LoadAuthors { authorFollowers(author_id: Int!, limit: Int) { id slug userpic name } }",
"operation": "LoadAuthors",
"variables": None
"variables": {
"author_id": author_id,
"limit": amount
}
}
followers = []
try: