Shared conversation update

This commit is contained in:
Tim O'Farrell 2025-12-17 14:04:20 -07:00
parent e724c1daed
commit 31c20e9bc7
4 changed files with 11 additions and 19 deletions

View File

@ -22,7 +22,7 @@ event_service_dependency = depends_event_service()
@router.get('/search')
async def search_events(
conversation_id__eq: Annotated[
UUID | None,
str | None,
Query(title='Optional filter by conversation ID'),
] = None,
kind__eq: Annotated[
@ -55,7 +55,7 @@ async def search_events(
assert limit > 0
assert limit <= 100
return await event_service.search_events(
conversation_id__eq=conversation_id__eq,
conversation_id__eq=UUID(conversation_id__eq) if conversation_id__eq else None,
kind__eq=kind__eq,
timestamp__gte=timestamp__gte,
timestamp__lt=timestamp__lt,
@ -68,7 +68,7 @@ async def search_events(
@router.get('/count')
async def count_events(
conversation_id__eq: Annotated[
UUID | None,
str | None,
Query(title='Optional filter by conversation ID'),
] = None,
kind__eq: Annotated[
@ -91,7 +91,7 @@ async def count_events(
) -> int:
"""Count events matching the given filters."""
return await event_service.count_events(
conversation_id__eq=conversation_id__eq,
conversation_id__eq=UUID(conversation_id__eq) if conversation_id__eq else None,
kind__eq=kind__eq,
timestamp__gte=timestamp__gte,
timestamp__lt=timestamp__lt,

View File

@ -16,13 +16,9 @@ from openhands.app_server.sharing.shared_conversation_models import (
SharedConversationSortOrder,
)
router = APIRouter(prefix='/shared-conversations', tags=['Shared Conversations'])
router = APIRouter(prefix='/shared-conversations', tags=['Sharing'])
shared_conversation_service_dependency = depends_shared_conversation_info_service()
# Attach dependency to router for testing
router.shared_conversation_service_dependency = shared_conversation_service_dependency
# Read methods

View File

@ -12,13 +12,9 @@ from openhands.app_server.event_callback.event_callback_models import EventKind
from openhands.app_server.sharing.shared_event_service import SharedEventService
from openhands.sdk import Event
router = APIRouter(prefix='/shared-events', tags=['Shared Events'])
router = APIRouter(prefix='/shared-events', tags=['Sharing'])
shared_event_service_dependency = depends_shared_event_service()
# Attach dependency to router for testing
router.shared_event_service_dependency = shared_event_service_dependency
# Read methods
@ -72,7 +68,7 @@ async def search_shared_events(
@router.get('/count')
async def count_shared_events(
conversation_id: Annotated[
UUID,
str,
Query(title='Conversation ID to count events for'),
],
kind__eq: Annotated[
@ -95,7 +91,7 @@ async def count_shared_events(
) -> int:
"""Count events for a shared conversation matching the given filters."""
return await shared_event_service.count_shared_events(
conversation_id=conversation_id,
conversation_id=UUID(conversation_id),
kind__eq=kind__eq,
timestamp__gte=timestamp__gte,
timestamp__lt=timestamp__lt,

View File

@ -44,12 +44,12 @@ class SharedEventServiceImpl(SharedEventService):
) -> Event | None:
"""Given a conversation_id and event_id, retrieve an event if the conversation is shared."""
# First check if the conversation is shared
public_conversation = (
shared_conversation_info = (
await self.shared_conversation_info_service.get_shared_conversation_info(
conversation_id
)
)
if public_conversation is None:
if shared_conversation_info is None:
return None
# If conversation is shared, get the event
@ -73,7 +73,7 @@ class SharedEventServiceImpl(SharedEventService):
)
)
if shared_conversation_info is None:
# Return empty page if conversation is not public
# Return empty page if conversation is not shared
return EventPage(items=[], next_page_id=None)
# If conversation is shared, search events for this conversation