from __future__ import annotations

from typing import Annotated

from fastapi import Depends
from sqlalchemy.ext.asyncio import AsyncSession

from core.auth.models import CurrentUser
from core.db import get_db
from v1.inbox_messages.repository import SQLAlchemyInboxMessageRepository
from v1.inbox_messages.service import InboxMessageService
from v1.users.dependencies import get_current_user


async def get_inbox_message_repository(
    session: Annotated[AsyncSession, Depends(get_db)],
) -> SQLAlchemyInboxMessageRepository:
    return SQLAlchemyInboxMessageRepository(session)


def get_inbox_message_service(
    session: Annotated[AsyncSession, Depends(get_db)],
    repository: Annotated[
        SQLAlchemyInboxMessageRepository, Depends(get_inbox_message_repository)
    ],
    user: Annotated[CurrentUser, Depends(get_current_user)],
) -> InboxMessageService:
    return InboxMessageService(
        repository=repository, session=session, current_user=user
    )
