mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-20 13:05:16 +00:00
fix: Add missing contact information to fix invalid activity messages (#4195)
Co-authored-by: Tejaswini <tejaswini@chatwoot.com>
This commit is contained in:
@@ -47,7 +47,7 @@ class Api::V1::Widget::ConversationsController < Api::V1::Widget::BaseController
|
|||||||
def toggle_status
|
def toggle_status
|
||||||
head :not_found && return if conversation.nil?
|
head :not_found && return if conversation.nil?
|
||||||
unless conversation.resolved?
|
unless conversation.resolved?
|
||||||
conversation.status = 'resolved'
|
conversation.status = :resolved
|
||||||
conversation.save
|
conversation.save
|
||||||
end
|
end
|
||||||
head :ok
|
head :ok
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ module WebsiteTokenHelper
|
|||||||
)
|
)
|
||||||
@contact = @contact_inbox&.contact
|
@contact = @contact_inbox&.contact
|
||||||
raise ActiveRecord::RecordNotFound unless @contact
|
raise ActiveRecord::RecordNotFound unless @contact
|
||||||
|
|
||||||
|
Current.contact = @contact
|
||||||
end
|
end
|
||||||
|
|
||||||
def permitted_params
|
def permitted_params
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ RSpec.describe '/api/v1/widget/conversations/toggle_typing', type: :request do
|
|||||||
context 'when user end conversation from widget' do
|
context 'when user end conversation from widget' do
|
||||||
it 'resolves the conversation' do
|
it 'resolves the conversation' do
|
||||||
expect(conversation.open?).to be true
|
expect(conversation.open?).to be true
|
||||||
|
|
||||||
get '/api/v1/widget/conversations/toggle_status',
|
get '/api/v1/widget/conversations/toggle_status',
|
||||||
headers: { 'X-Auth-Token' => token },
|
headers: { 'X-Auth-Token' => token },
|
||||||
params: { website_token: web_widget.website_token },
|
params: { website_token: web_widget.website_token },
|
||||||
@@ -130,6 +131,15 @@ RSpec.describe '/api/v1/widget/conversations/toggle_typing', type: :request do
|
|||||||
|
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
expect(conversation.reload.resolved?).to be true
|
expect(conversation.reload.resolved?).to be true
|
||||||
|
expect(Conversations::ActivityMessageJob).to have_been_enqueued.at_least(:once).with(
|
||||||
|
conversation,
|
||||||
|
{
|
||||||
|
account_id: conversation.account_id,
|
||||||
|
inbox_id: conversation.inbox_id,
|
||||||
|
message_type: :activity,
|
||||||
|
content: "Conversation was resolved by #{contact.name}"
|
||||||
|
}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user