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

@ -62,7 +62,7 @@ input MessagesBy {
type Query { type Query {
# inbox # inbox
loadChats( limit: Int, offset: Int): ChatResult! # your chats loadChats(limit: Int, offset: Int): ChatResult! # your chats
loadMessagesBy(by: MessagesBy!, limit: Int, offset: Int): ChatResult! loadMessagesBy(by: MessagesBy!, limit: Int, offset: Int): ChatResult!
loadRecipients(limit: Int, offset: Int): ChatResult! loadRecipients(limit: Int, offset: Int): ChatResult!
searchRecipients(query: String!, limit: Int, offset: Int): ChatResult! searchRecipients(query: String!, limit: Int, offset: Int): ChatResult!

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 [] members_online = (await redis.execute("SMEMBERS", "authors-online")) or []
chats = [] chats = []
if len(cids) == 0: 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"]) cids.append(r["chat"]["id"])
for cid in cids: for cid in cids:
c = await redis.execute("GET", f"chats/{cid}") 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): async def get_author(author_id):
gql = { gql = {
"query": "query GetAuthor { getAuthor(author_id: %s) { id slug userpic name lastSeen } }" "query": "query GetAuthor { getAuthor(author_id: Int!) { id slug userpic name lastSeen } }",
% author_id,
"operation": "GetAuthor", "operation": "GetAuthor",
"variables": None "variables": { "author_id" : author_id }
} }
try: try:
async with AsyncClient() as client: 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: async def get_network(author_id, limit=50, offset=0) -> list:
gql = { gql = {
"query": "query LoadAuthors { authorFollowings(author_id: %s, limit: %s, offset: %s) { id slug userpic name } }" "query": "query LoadAuthors { authorFollowings(author_id: Int!, limit: Int, offset: Int) { id slug userpic name } }",
% (author_id, limit, offset),
"operation": "LoadAuthors", "operation": "LoadAuthors",
"variables": None "variables": {
"author_id": author_id,
"limit": limit,
"offset": offset
}
} }
followings = [] followings = []
@ -56,10 +58,12 @@ async def get_network(author_id, limit=50, offset=0) -> list:
async def get_followers(author_id, amount): async def get_followers(author_id, amount):
gql = { gql = {
"query": "query LoadAuthors { authorFollowers(author_id: %s, limit: %s) { id slug userpic name } }" "query": "query LoadAuthors { authorFollowers(author_id: Int!, limit: Int) { id slug userpic name } }",
% (author_id, amount),
"operation": "LoadAuthors", "operation": "LoadAuthors",
"variables": None "variables": {
"author_id": author_id,
"limit": amount
}
} }
followers = [] followers = []
try: try: