format+fix
Some checks failed
deploy / deploy (push) Failing after 1m7s

This commit is contained in:
2023-11-14 21:25:55 +03:00
parent 4f3a0dc788
commit 4ecdc08dfc
6 changed files with 20 additions and 21 deletions

View File

@@ -16,7 +16,7 @@ async def check_auth(req):
query_type = "mutation" if INTERNAL_AUTH_SERVER else "query"
operation = "GetUserId"
headers = {"Authorization": token, "Content-Type": "application/json"} # "Bearer " + removed
headers = {"Authorization": token, "Content-Type": "application/json"} # "Bearer " + removed
gql = {
"query": query_type + " " + operation + " { " + query_name + " { user { id } } " + " }",

View File

@@ -2,14 +2,15 @@ from httpx import AsyncClient
from settings import API_BASE
headers = {"Content-Type": "application/json"}
INTERNAL_AUTH_SERVER = 'v2.' in API_BASE
INTERNAL_AUTH_SERVER = "v2." in API_BASE
async def get_all_authors():
query_name = "authorsAll"
query_type = "query"
operation = "AuthorsAll"
query_fields = "id slug userpic name"
headers = {"Content-Type": "application/json"} # "Bearer " + removed
headers = {"Content-Type": "application/json"} # "Bearer " + removed
gql = {
"query": query_type + " " + operation + " { " + query_name + " { " + query_fields + " } " + " }",
@@ -21,6 +22,7 @@ async def get_all_authors():
response = await client.post(API_BASE, headers=headers, json=gql)
except Exception:
import traceback
traceback.print_exc()
print(f"[services.core] {query_name}: {response.status_code} {response.text}")
if response.status_code != 200:
@@ -34,7 +36,7 @@ async def get_my_followings():
query_type = "query"
operation = "LoadMySubscriptions"
query_fields = "id slug userpic name"
headers = {"Content-Type": "application/json"} # "Bearer " + removed
headers = {"Content-Type": "application/json"} # "Bearer " + removed
gql = {
"query": query_type + " " + operation + " { " + query_name + " { authors {" + query_fields + "} } " + " }",
@@ -46,6 +48,7 @@ async def get_my_followings():
response = await client.post(API_BASE, headers=headers, json=gql)
except Exception:
import traceback
traceback.print_exc()
print(f"[services.core] {query_name}: {response.status_code} {response.text}")
if response.status_code != 200:
@@ -53,8 +56,3 @@ async def get_my_followings():
r = response.json()
authors = r.get("data", {}).get(query_name).get("authors", [])
return authors
members = get_all_authors() # [ { id slug name userpic }, ..]
print(f"[services.core] cache members amount: {len(members)}")
members_by_slug = {member['slug']: member for member in members}
members_by_id = {member['id']: member for member in members}

View File

@@ -4,7 +4,7 @@ from services.rediscache import redis
from validators.chat import Message
async def notify_message(message: Message, chat_id: str, action = "create"):
async def notify_message(message: Message, chat_id: str, action="create"):
channel_name = f"chat:{chat_id}"
data = {"payload": message, "action": action}
try: