|
3 | 3 | import logging |
4 | 4 | from typing import Any |
5 | 5 |
|
6 | | -from fastapi import APIRouter, Request, Depends, HTTPException, status |
| 6 | +from fastapi import APIRouter, Depends, HTTPException, Request, status |
7 | 7 |
|
8 | | -from configuration import configuration |
9 | 8 | from authentication import get_auth_dependency |
10 | 9 | from authorization.middleware import authorize |
| 10 | +from configuration import configuration |
11 | 11 | from models.cache_entry import CacheEntry |
12 | 12 | from models.config import Action |
13 | 13 | from models.responses import ( |
14 | | - ConversationsListResponseV2, |
15 | | - ConversationResponse, |
16 | 14 | ConversationDeleteResponse, |
| 15 | + ConversationResponse, |
| 16 | + ConversationsListResponseV2, |
17 | 17 | UnauthorizedResponse, |
18 | 18 | ) |
19 | 19 | from utils.endpoints import check_configuration_loaded |
20 | 20 | from utils.suid import check_suid |
21 | 21 |
|
22 | 22 | logger = logging.getLogger("app.endpoints.handlers") |
23 | 23 | router = APIRouter(tags=["conversations_v2"]) |
24 | | -auth_dependency = get_auth_dependency() |
25 | 24 |
|
26 | 25 |
|
27 | 26 | conversation_responses: dict[int | str, dict[str, Any]] = { |
|
95 | 94 | @authorize(Action.LIST_CONVERSATIONS) |
96 | 95 | async def get_conversations_list_endpoint_handler( |
97 | 96 | request: Request, # pylint: disable=unused-argument |
98 | | - auth: Any = Depends(auth_dependency), |
| 97 | + auth: Any = Depends(get_auth_dependency()), |
99 | 98 | ) -> ConversationsListResponseV2: |
100 | 99 | """Handle request to retrieve all conversations for the authenticated user.""" |
101 | 100 | check_configuration_loaded(configuration) |
@@ -127,7 +126,7 @@ async def get_conversations_list_endpoint_handler( |
127 | 126 | async def get_conversation_endpoint_handler( |
128 | 127 | request: Request, # pylint: disable=unused-argument |
129 | 128 | conversation_id: str, |
130 | | - auth: Any = Depends(auth_dependency), |
| 129 | + auth: Any = Depends(get_auth_dependency()), |
131 | 130 | ) -> ConversationResponse: |
132 | 131 | """Handle request to retrieve a conversation by ID.""" |
133 | 132 | check_configuration_loaded(configuration) |
@@ -167,7 +166,7 @@ async def get_conversation_endpoint_handler( |
167 | 166 | async def delete_conversation_endpoint_handler( |
168 | 167 | request: Request, # pylint: disable=unused-argument |
169 | 168 | conversation_id: str, |
170 | | - auth: Any = Depends(auth_dependency), |
| 169 | + auth: Any = Depends(get_auth_dependency()), |
171 | 170 | ) -> ConversationDeleteResponse: |
172 | 171 | """Handle request to delete a conversation by ID.""" |
173 | 172 | check_configuration_loaded(configuration) |
|
0 commit comments