chore: Improve the behavior of lock to single conversation (#7899)

This commit is contained in:
Sojan Jose
2023-09-14 00:02:57 -07:00
committed by GitHub
parent 2d4ef0c328
commit 616371adbb
7 changed files with 148 additions and 13 deletions

View File

@@ -57,7 +57,13 @@ class Sms::IncomingMessageService
end
def set_conversation
@conversation = @contact_inbox.conversations.last
# if lock to single conversation is disabled, we will create a new conversation if previous conversation is resolved
@conversation = if @inbox.lock_to_single_conversation
@contact_inbox.conversations.last
else
@contact_inbox.conversations.where
.not(status: :resolved).last
end
return if @conversation
@conversation = ::Conversation.create!(conversation_params)

View File

@@ -72,7 +72,13 @@ class Twilio::IncomingMessageService
end
def set_conversation
@conversation = @contact_inbox.conversations.first
# if lock to single conversation is disabled, we will create a new conversation if previous conversation is resolved
@conversation = if @inbox.lock_to_single_conversation
@contact_inbox.conversations.last
else
@contact_inbox.conversations.where
.not(status: :resolved).last
end
return if @conversation
@conversation = ::Conversation.create!(conversation_params)

View File

@@ -91,7 +91,13 @@ class Whatsapp::IncomingMessageBaseService
end
def set_conversation
@conversation = @contact_inbox.conversations.last
# if lock to single conversation is disabled, we will create a new conversation if previous conversation is resolved
@conversation = if @inbox.lock_to_single_conversation
@contact_inbox.conversations.last
else
@contact_inbox.conversations
.where.not(status: :resolved).last
end
return if @conversation
@conversation = ::Conversation.create!(conversation_params)