Parse only if message is outgoing

This commit is contained in:
Muhsin 2022-12-16 00:01:30 +05:30
parent f65d45a01a
commit e03285e702
2 changed files with 2 additions and 2 deletions

View file

@ -149,7 +149,7 @@ class Message < ApplicationRecord
end end
def process_liquid_in_content def process_liquid_in_content
return if content.blank? return if content.blank? || message_type != 'outgoing'
template = Liquid::Template.parse(content) template = Liquid::Template.parse(content)

View file

@ -214,7 +214,7 @@ RSpec.describe Message, type: :model do
context 'when message is created with variables' do context 'when message is created with variables' do
let(:contact) { create(:contact, name: 'john', phone_number: '+912883') } let(:contact) { create(:contact, name: 'john', phone_number: '+912883') }
let(:conversation) { create(:conversation, id: 1, contact: contact) } let(:conversation) { create(:conversation, id: 1, contact: contact) }
let(:message) { build(:message, conversation: conversation) } let(:message) { build(:message, conversation: conversation, message_type: 'outgoing') }
it 'set contact name variable in message' do it 'set contact name variable in message' do
message.content = 'hey {{contact.name}} how are you?' message.content = 'hey {{contact.name}} how are you?'