38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from typing import Annotated
|
|
|
|
import asyncpg
|
|
from dishka.integrations.fastapi import DishkaRoute, FromDishka
|
|
from fastapi import APIRouter, Query
|
|
|
|
from utils.read import social
|
|
from utils.read.models import CallbackView, LinkView, ReactionView
|
|
|
|
router = APIRouter(
|
|
prefix="/api/messages/{chat_id}/{message_id}",
|
|
tags=["social"],
|
|
route_class=DishkaRoute,
|
|
)
|
|
|
|
AccountId = Annotated[int, Query()]
|
|
|
|
|
|
@router.get("/callbacks")
|
|
async def message_callbacks(
|
|
pool: FromDishka[asyncpg.Pool], chat_id: int, message_id: int, account_id: AccountId
|
|
) -> list[CallbackView]:
|
|
return await social.get_callbacks(pool, account_id, chat_id, message_id)
|
|
|
|
|
|
@router.get("/reactions")
|
|
async def message_reactions(
|
|
pool: FromDishka[asyncpg.Pool], chat_id: int, message_id: int, account_id: AccountId
|
|
) -> list[ReactionView]:
|
|
return await social.get_reactions(pool, account_id, chat_id, message_id)
|
|
|
|
|
|
@router.get("/links")
|
|
async def message_links(
|
|
pool: FromDishka[asyncpg.Pool], chat_id: int, message_id: int, account_id: AccountId
|
|
) -> list[LinkView]:
|
|
return await social.get_links(pool, account_id, chat_id, message_id)
|