validators
This commit is contained in:
@@ -11,12 +11,16 @@ async def get_author(author_id):
|
||||
gql = {
|
||||
"query": "query GetAuthorById($author_id: Int!) { getAuthorById(author_id: $author_id) { id slug userpic name lastSeen } }",
|
||||
"operation": "GetAuthorById",
|
||||
"variables": {"author_id": author_id}
|
||||
"variables": {"author_id": author_id},
|
||||
}
|
||||
async with AsyncClient() as client:
|
||||
try:
|
||||
response = await client.post(API_BASE, headers=headers, data=json.dumps(gql))
|
||||
print(f"[services.core] get_author response: {response.status_code} {response.text}")
|
||||
response = await client.post(
|
||||
API_BASE, headers=headers, data=json.dumps(gql)
|
||||
)
|
||||
print(
|
||||
f"[services.core] get_author response: {response.status_code} {response.text}"
|
||||
)
|
||||
if response.status_code != 200:
|
||||
return None
|
||||
r = response.json()
|
||||
@@ -27,21 +31,19 @@ async def get_author(author_id):
|
||||
return None
|
||||
|
||||
|
||||
async def get_network(author_id:int, limit:int = 50, offset:int = 0) -> list:
|
||||
async def get_network(author_id: int, limit: int = 50, offset: int = 0) -> list:
|
||||
gql = {
|
||||
"query": "query LoadAuthors($author_id: Int!, $limit: Int, $offset: Int) { authorFollowings(author_id: $author_id, limit: $limit, offset: $offset) { id slug userpic name } }",
|
||||
"operation": "LoadAuthors",
|
||||
"variables": {
|
||||
"author_id": author_id,
|
||||
"limit": limit,
|
||||
"offset": offset
|
||||
}
|
||||
"variables": {"author_id": author_id, "limit": limit, "offset": offset},
|
||||
}
|
||||
|
||||
followings = []
|
||||
try:
|
||||
async with AsyncClient() as client:
|
||||
response = await client.post(API_BASE, headers=headers, data=json.dumps(gql))
|
||||
response = await client.post(
|
||||
API_BASE, headers=headers, data=json.dumps(gql)
|
||||
)
|
||||
if response.status_code != 200:
|
||||
return []
|
||||
r = response.json()
|
||||
@@ -60,15 +62,14 @@ async def get_followers(author_id, amount):
|
||||
gql = {
|
||||
"query": "query LoadAuthors($author_id: Int!, $limit: Int, $offset: Int) { authorFollowers(author_id: $author_id, limit: $limit) { id slug userpic name } }",
|
||||
"operation": "LoadAuthors",
|
||||
"variables": {
|
||||
"author_id": author_id,
|
||||
"limit": amount
|
||||
}
|
||||
"variables": {"author_id": author_id, "limit": amount},
|
||||
}
|
||||
followers = []
|
||||
try:
|
||||
async with AsyncClient() as client:
|
||||
response = await client.post(API_BASE, headers=headers, data=json.dumps(gql))
|
||||
response = await client.post(
|
||||
API_BASE, headers=headers, data=json.dumps(gql)
|
||||
)
|
||||
if response.status_code != 200:
|
||||
return []
|
||||
r = response.json()
|
||||
|
Reference in New Issue
Block a user