feat: block replies during agent bot ownership

This commit is contained in:
Sojan Jose
2026-06-28 20:10:46 -07:00
parent d0b1c055e8
commit b9834c3a18
7 changed files with 94 additions and 12 deletions
@@ -36,6 +36,33 @@ RSpec.describe 'Conversation Messages API', type: :request do
expect(conversation.messages.first.content).to eq(params[:content])
end
it 'blocks public replies when an agent bot owns the conversation' do
conversation.update!(assignee_agent_bot: create(:agent_bot, account: account))
params = { content: 'test-message', private: false }
post api_v1_account_conversation_messages_url(account_id: account.id, conversation_id: conversation.display_id),
params: params,
headers: agent.create_new_auth_token,
as: :json
expect(response).to have_http_status(:unprocessable_entity)
expect(response.parsed_body['error']).to eq('Conversation is assigned to an Agent Bot. Take over the conversation before replying.')
expect(conversation.messages.count).to eq(0)
end
it 'allows private notes when an agent bot owns the conversation' do
conversation.update!(assignee_agent_bot: create(:agent_bot, account: account))
params = { content: 'test-note', private: true }
post api_v1_account_conversation_messages_url(account_id: account.id, conversation_id: conversation.display_id),
params: params,
headers: agent.create_new_auth_token,
as: :json
expect(response).to have_http_status(:success)
expect(conversation.messages.last).to be_private
end
it 'does not create the message' do
params = { content: "#{'h' * 150 * 1000}a", private: true }