|
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]] = { |
|
93 | 92 | @authorize(Action.LIST_CONVERSATIONS) |
94 | 93 | async def get_conversations_list_endpoint_handler( |
95 | 94 | request: Request, # pylint: disable=unused-argument |
96 | | - auth: Any = Depends(auth_dependency), |
| 95 | + auth: Any = Depends(get_auth_dependency()), |
97 | 96 | ) -> ConversationsListResponseV2: |
98 | 97 | """Handle request to retrieve all conversations for the authenticated user.""" |
99 | 98 | check_configuration_loaded(configuration) |
@@ -123,7 +122,7 @@ async def get_conversations_list_endpoint_handler( |
123 | 122 | async def get_conversation_endpoint_handler( |
124 | 123 | request: Request, # pylint: disable=unused-argument |
125 | 124 | conversation_id: str, |
126 | | - auth: Any = Depends(auth_dependency), |
| 125 | + auth: Any = Depends(get_auth_dependency()), |
127 | 126 | ) -> ConversationResponse: |
128 | 127 | """Handle request to retrieve a conversation by ID.""" |
129 | 128 | check_configuration_loaded(configuration) |
@@ -159,7 +158,7 @@ async def get_conversation_endpoint_handler( |
159 | 158 | async def delete_conversation_endpoint_handler( |
160 | 159 | request: Request, # pylint: disable=unused-argument |
161 | 160 | conversation_id: str, |
162 | | - auth: Any = Depends(auth_dependency), |
| 161 | + auth: Any = Depends(get_auth_dependency()), |
163 | 162 | ) -> ConversationDeleteResponse: |
164 | 163 | """Handle request to delete a conversation by ID.""" |
165 | 164 | check_configuration_loaded(configuration) |
|
0 commit comments