dev@locazia: fix sendStatus

This commit is contained in:
user committed 2024-03-03 14:33:23 +03:00
1 parent 64e86f360d
commit 8e37098057
5 files changed
+38 -22

No files matched your search

+20 -18
View File
@@ -9,21 +9,23 @@ from app.core._crypto.signer import Signer
async def send_status(service: str, status: str):
message = {
'service': service,
'status': status,
}
message_bytes = dumps(message).encode()
signer = Signer(hot_seed)
message_signature = signer.sign(message_bytes)
async with AsyncClient() as client:
res = await client.post(
f"{PROJECT_HOST}/api/system.sendStatus",
json={
'message': b58encode(message_bytes).decode(),
'signature': message_signature,
}
)
if res.status_code != 200:
make_log("send_status", f"Error (service={service}, status={status}, response={res.text})", level='error')
try:
message = {
'service': service,
'status': status,
}
message_bytes = dumps(message).encode()
signer = Signer(hot_seed)
message_signature = signer.sign(message_bytes)
async with AsyncClient() as client:
res = await client.post(
f"{PROJECT_HOST}/api/system.sendStatus",
json={
'message': b58encode(message_bytes).decode(),
'signature': message_signature,
}
)
if res.status_code != 200:
make_log("send_status", f"Error (service={service}, status={status}, response={res.text})", level='error')
except BaseException as e:
make_log("send_status", f"Error: {e}", level='error')