This commit is contained in:
parent
284a69085f
commit
876087c528
|
@ -21,13 +21,9 @@ async def _request_endpoint(query_name, body) -> Any:
|
||||||
|
|
||||||
async def get_all_authors() -> List[ChatMember]:
|
async def get_all_authors() -> List[ChatMember]:
|
||||||
query_name = "authorsAll"
|
query_name = "authorsAll"
|
||||||
query_type = "query"
|
|
||||||
operation = "AuthorsAll"
|
|
||||||
query_fields = "id slug pic name"
|
|
||||||
|
|
||||||
gql = {
|
gql = {
|
||||||
"query": query_type + " " + operation + " { " + query_name + " { " + query_fields + " } " + " }",
|
"query": "query { " + query_name + " { id slug pic name } }",
|
||||||
"operationName": operation,
|
|
||||||
"variables": None,
|
"variables": None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,30 +32,15 @@ async def get_all_authors() -> List[ChatMember]:
|
||||||
|
|
||||||
async def get_my_followed() -> List[ChatMember]:
|
async def get_my_followed() -> List[ChatMember]:
|
||||||
query_name = "get_my_followed"
|
query_name = "get_my_followed"
|
||||||
query_type = "query"
|
|
||||||
operation = "GetMyFollowed"
|
|
||||||
query_fields = "id slug pic name"
|
|
||||||
|
|
||||||
gql = {
|
gql = {
|
||||||
"query": query_type + " " + operation + " { " + query_name + " { authors {" + query_fields + "} } " + " }",
|
"query": "query { " + query_name + " { authors { id slug pic name } } }",
|
||||||
"operationName": operation,
|
|
||||||
"variables": None,
|
"variables": None,
|
||||||
}
|
}
|
||||||
|
|
||||||
async with ClientSession() as client:
|
result = await _request_endpoint(query_name, gql)
|
||||||
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
|
|
||||||
|
|
||||||
traceback.print_exc()
|
return result.get("authors", [])
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
async def get_author(user: str = ""):
|
async def get_author(user: str = ""):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user