core-connectors-upgrade
All checks were successful
deploy / deploy (push) Successful in 1m4s

This commit is contained in:
Untone 2023-12-18 10:24:42 +03:00
parent 284a69085f
commit 876087c528

View File

@ -21,13 +21,9 @@ async def _request_endpoint(query_name, body) -> Any:
async def get_all_authors() -> List[ChatMember]:
query_name = "authorsAll"
query_type = "query"
operation = "AuthorsAll"
query_fields = "id slug pic name"
gql = {
"query": query_type + " " + operation + " { " + query_name + " { " + query_fields + " } " + " }",
"operationName": operation,
"query": "query { " + query_name + " { id slug pic name } }",
"variables": None,
}
@ -36,30 +32,15 @@ async def get_all_authors() -> List[ChatMember]:
async def get_my_followed() -> List[ChatMember]:
query_name = "get_my_followed"
query_type = "query"
operation = "GetMyFollowed"
query_fields = "id slug pic name"
gql = {
"query": query_type + " " + operation + " { " + query_name + " { authors {" + query_fields + "} } " + " }",
"operationName": operation,
"query": "query { " + query_name + " { authors { id slug pic name } } }",
"variables": None,
}
async with ClientSession() as client:
try:
response: ClientResponse = await client.post(API_BASE, headers=headers, json=gql)
print(f"[services.core] {query_name}: [{response.status}] {len(response.text)} bytes")
if response.status_code != 200:
return []
r = response.json()
if r:
return r.get("data", {}).get(query_name, {}).get("authors", [])
except Exception:
import traceback
result = await _request_endpoint(query_name, gql)
traceback.print_exc()
return []
return result.get("authors", [])
async def get_author(user: str = ""):