chore: Disable invalid contact resolved activity messages (#4253)

Fixes the bug which triggered "Contact resolved conversation" activity messages when snoozed conversations where reopened
This commit is contained in:
Sojan Jose 2022-03-23 16:08:42 +05:30 committed by GitHub
parent 771cb5b9fc
commit f8c46341f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View file

@ -20,7 +20,7 @@ module ActivityMessageHandler
def create_status_change_message(user_name)
content = if user_name
I18n.t("conversations.activity.status.#{status}", user_name: user_name)
elsif Current.contact.present?
elsif Current.contact.present? && resolved?
I18n.t('conversations.activity.status.contact_resolved', contact_name: Current.contact.name.capitalize)
elsif resolved?
I18n.t('conversations.activity.status.auto_resolved', duration: auto_resolve_duration)

View file

@ -87,6 +87,28 @@ RSpec.describe '/api/v1/widget/messages', type: :request do
expect(response).to have_http_status(:success)
expect(conversation.reload.resolved?).to eq(true)
end
it 'does not create resolved activity messages when snoozed conversation is opened' do
conversation.snoozed!
message_params = { content: 'hello world', timestamp: Time.current }
post api_v1_widget_messages_url,
params: { website_token: web_widget.website_token, message: message_params },
headers: { 'X-Auth-Token' => token },
as: :json
expect(Conversations::ActivityMessageJob).not_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}"
}
)
expect(response).to have_http_status(:success)
expect(conversation.reload.open?).to eq(true)
end
end
end