feat: send instagram message after 24 hours (#4698)

Added MESSAGE_TAG: HUMAN_AGENT for Instagram messages if the user wants to send it after the standard message window.

Fixes #4689
This commit is contained in:
Tejaswini Chile
2022-05-26 19:05:30 +05:30
committed by GitHub
parent 1215f37dda
commit 47a6d9681a
5 changed files with 122 additions and 14 deletions

View File

@@ -512,6 +512,38 @@ RSpec.describe Conversation, type: :model do
)
expect(conversation.can_reply?).to eq true
end
context 'when instagram channel' do
it 'return true with HUMAN_AGENT if it is outside of 24 hour window' do
InstallationConfig.where(name: 'ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT').first_or_create(value: true)
conversation.update(additional_attributes: { type: 'instagram_direct_message' })
create(
:message,
account: conversation.account,
inbox: facebook_inbox,
conversation: conversation,
created_at: Time.now - 48.hours
)
expect(conversation.can_reply?).to eq true
end
it 'return false without HUMAN_AGENT if it is outside of 24 hour window' do
InstallationConfig.where(name: 'ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT').first_or_create(value: false)
conversation.update(additional_attributes: { type: 'instagram_direct_message' })
create(
:message,
account: conversation.account,
inbox: facebook_inbox,
conversation: conversation,
created_at: Time.now - 48.hours
)
expect(conversation.can_reply?).to eq false
end
end
end
end