add internal msg

This commit is contained in:
unknown 2025-10-15 01:25:16 +03:00
parent f46f3904e5
commit bfc63823bd
2 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,27 @@
import httpx
from uuid import UUID
from fastapi import HTTPException, status
from config import settings
from common_lib.utils.http_client import client
async def send_internal_message(sender: str, user_id: UUID, content: str) -> dict:
try:
response = await client.post(
f"{settings.CHAT_PRIVATE_SERVICE}/internal/send",
json={"sender": str(sender),
"user_id": str(user_id),
"content": str(content)
})
if response.status_code != 200:
raise HTTPException(
status_code=response.status_code,
detail=f"chat_private_service: {response.text}"
)
wrapped = response.json()
return wrapped["data"]
except httpx.RequestError as e:
raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE, detail=f"chat_private_service unreachable: {str(e)}")

View File

@ -1,6 +1,6 @@
[project]
name = "common-lib"
version = "0.0.23"
version = "0.0.24"
description = "Библиотека общих компонентов для микросервисов yobble"
authors = [{ name = "cheykrym", email = "you@example.com" }]
license = "MIT"