feat: Ability to lock to single conversation (#5881)

Adds the ability to lock conversation to a single thread for Whatsapp and Sms Inboxes when using outbound messages.

demo: https://www.loom.com/share/c9e1e563c8914837a4139dfdd2503fef

fixes: #4975

Co-authored-by: Nithin David <1277421+nithindavid@users.noreply.github.com>
This commit is contained in:
Sojan Jose
2022-11-25 13:01:04 +03:00
committed by GitHub
parent 8813c77907
commit b05d06a28a
13 changed files with 171 additions and 47 deletions

View File

@@ -265,17 +265,18 @@ RSpec.describe 'Conversations API', type: :request do
# TODO: remove this spec when we remove the condition check in controller
# Added for backwards compatibility for bot status
it 'creates a conversation as pending if status is specified as bot' do
allow(Rails.configuration.dispatcher).to receive(:dispatch)
post "/api/v1/accounts/#{account.id}/conversations",
headers: agent.create_new_auth_token,
params: { source_id: contact_inbox.source_id, status: 'bot' },
as: :json
# remove this in subsequent release
# it 'creates a conversation as pending if status is specified as bot' do
# allow(Rails.configuration.dispatcher).to receive(:dispatch)
# post "/api/v1/accounts/#{account.id}/conversations",
# headers: agent.create_new_auth_token,
# params: { source_id: contact_inbox.source_id, status: 'bot' },
# as: :json
expect(response).to have_http_status(:success)
response_data = JSON.parse(response.body, symbolize_names: true)
expect(response_data[:status]).to eq('pending')
end
# expect(response).to have_http_status(:success)
# response_data = JSON.parse(response.body, symbolize_names: true)
# expect(response_data[:status]).to eq('pending')
# end
it 'creates a new conversation with message when message is passed' do
allow(Rails.configuration.dispatcher).to receive(:dispatch)
@@ -408,17 +409,18 @@ RSpec.describe 'Conversations API', type: :request do
# TODO: remove this spec when we remove the condition check in controller
# Added for backwards compatibility for bot status
it 'toggles the conversation status to pending status when parameter bot is passed' do
expect(conversation.status).to eq('open')
# remove in next release
# it 'toggles the conversation status to pending status when parameter bot is passed' do
# expect(conversation.status).to eq('open')
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/toggle_status",
headers: agent.create_new_auth_token,
params: { status: 'bot' },
as: :json
# post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/toggle_status",
# headers: agent.create_new_auth_token,
# params: { status: 'bot' },
# as: :json
expect(response).to have_http_status(:success)
expect(conversation.reload.status).to eq('pending')
end
# expect(response).to have_http_status(:success)
# expect(conversation.reload.status).to eq('pending')
# end
end
end