From 876087c5285739692de70bf210eac15091a33d86 Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 18 Dec 2023 10:24:42 +0300 Subject: [PATCH] core-connectors-upgrade --- services/core.py | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/services/core.py b/services/core.py index f1f99c3..04748fd 100644 --- a/services/core.py +++ b/services/core.py @@ -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 = ""):