From d40b0957ec055f6c6d9cf1203b2d69ada67fc2ec Mon Sep 17 00:00:00 2001 From: Erez Sharim Date: Thu, 4 Jul 2024 14:53:25 +0300 Subject: [PATCH] fix: don't stream ended conversations --- app/routers/conversation.py | 6 ++++++ app/slack/event_message.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/routers/conversation.py b/app/routers/conversation.py index 02e4b7e..2a7a1fd 100644 --- a/app/routers/conversation.py +++ b/app/routers/conversation.py @@ -224,6 +224,12 @@ def _add_messages(ai_content: str): status_code=status.HTTP_404_NOT_FOUND, detail="conversation not found" ) + if ar.status == ConversationStatuses.completed: + raise HTTPException( + status_code=status.HTTP_412_PRECONDITION_FAILED, + detail="conversation has ended, please start a new one", + ) + if ( admin_or_scope.is_admin is not True and ar.assignee != admin_or_scope.current_user_email diff --git a/app/slack/event_message.py b/app/slack/event_message.py index b1e49cf..1420ad5 100644 --- a/app/slack/event_message.py +++ b/app/slack/event_message.py @@ -95,7 +95,7 @@ def answer(client: WebClient, event, logger, say, context): logger.info("conversation %s created from slack", conversation.id) elif conversation.status == ConversationStatuses.completed: say( - text="This conversation is ended, please start a new one.", + text="This conversation has ended, please start a new one.", thread_ts=thread_ts, ) return