feat: Enable sending template messages in webhooks (#7252)

fixes: https://github.com/chatwoot/chatwoot/issues/5291
This commit is contained in:
Sojan Jose
2023-06-05 20:27:28 +05:30
committed by GitHub
parent b333d0c986
commit d03924b846
2 changed files with 17 additions and 1 deletions

View File

@@ -6,7 +6,7 @@ module MessageFilterHelpers
end
def webhook_sendable?
incoming? || outgoing?
incoming? || outgoing? || template?
end
def slack_hook_sendable?

View File

@@ -31,6 +31,22 @@ RSpec.describe Message do
it_behaves_like 'liqudable'
end
describe 'message_filter_helpers' do
context 'when webhook_sendable?' do
[
{ type: :incoming, expected: true },
{ type: :outgoing, expected: true },
{ type: :template, expected: true },
{ type: :activity, expected: false }
].each do |scenario|
it "returns #{scenario[:expected]} for #{scenario[:type]} message" do
message = create(:message, message_type: scenario[:type])
expect(message.webhook_sendable?).to eq(scenario[:expected])
end
end
end
end
describe 'Check if message is a valid first reply' do
it 'is valid if it is outgoing' do
outgoing_message = create(:message, message_type: :outgoing)