pyproject-build

This commit is contained in:
2023-10-14 14:52:04 +03:00
parent bc2fc7c9a0
commit 499893e10b
13 changed files with 100 additions and 75 deletions

View File

@@ -47,7 +47,7 @@ async def check_auth(req):
is_authenticated = user_id is not None
return is_authenticated, user_id
except Exception as e:
print(f"response contains no proper data: {r}")
print(f"{e}: {r}")
return False, None

View File

@@ -9,7 +9,9 @@ headers = {"Content-Type": "application/json"}
async def get_author(author_id):
gql = {
"query": "query GetAuthorById($author_id: Int!) { getAuthorById(author_id: $author_id) { id slug userpic name lastSeen } }",
"query": '''query GetAuthorById($author_id: Int!) {
getAuthorById(author_id: $author_id) { id slug userpic name lastSeen }
}''',
"operation": "GetAuthorById",
"variables": {"author_id": author_id},
}
@@ -18,9 +20,7 @@ async def get_author(author_id):
response = await client.post(
API_BASE, headers=headers, data=json.dumps(gql)
)
print(
f"[services.core] get_author response: {response.status_code} {response.text}"
)
print(f"[services.core] get_author: {response.status_code} {response.text}")
if response.status_code != 200:
return None
r = response.json()
@@ -33,7 +33,11 @@ async def get_author(author_id):
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 } }",
"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},
}
@@ -60,7 +64,11 @@ async def get_network(author_id: int, limit: int = 50, offset: int = 0) -> list:
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 } }",
"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},
}
@@ -75,5 +83,6 @@ async def get_followers(author_id, amount):
r = response.json()
followers = r.get("data", {}).get("authorFollowers", [])
except Exception as e:
print(e)
followers = []
return followers

View File

@@ -1,6 +1,6 @@
import json
from services.redis import redis
from validators.chat import Message
from validators.inbox import Message
async def notify_message(message: Message, chat_id: str):