mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 14:57:59 -05:00
refactor: make /events endpoint lightweight without requiring active conversation (#9685)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -3,9 +3,14 @@ import uuid
|
||||
from fastapi import Depends, HTTPException, Request, status
|
||||
|
||||
from openhands.core.logger import openhands_logger as logger
|
||||
from openhands.server.shared import ConversationStoreImpl, config, conversation_manager
|
||||
from openhands.server.shared import (
|
||||
ConversationStoreImpl,
|
||||
config,
|
||||
conversation_manager,
|
||||
)
|
||||
from openhands.server.user_auth import get_user_id
|
||||
from openhands.storage.conversation.conversation_store import ConversationStore
|
||||
from openhands.storage.data_models.conversation_metadata import ConversationMetadata
|
||||
|
||||
|
||||
async def get_conversation_store(request: Request) -> ConversationStore | None:
|
||||
@@ -29,6 +34,21 @@ async def generate_unique_conversation_id(
|
||||
return conversation_id
|
||||
|
||||
|
||||
async def get_conversation_metadata(
|
||||
conversation_id: str,
|
||||
conversation_store: ConversationStore = Depends(get_conversation_store),
|
||||
) -> ConversationMetadata:
|
||||
"""Get conversation metadata and validate user access without requiring an active conversation."""
|
||||
try:
|
||||
metadata = await conversation_store.get_metadata(conversation_id)
|
||||
return metadata
|
||||
except FileNotFoundError:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail=f'Conversation {conversation_id} not found',
|
||||
)
|
||||
|
||||
|
||||
async def get_conversation(
|
||||
conversation_id: str, user_id: str | None = Depends(get_user_id)
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user