feat: backend Changes in Message Handling
This commit is contained in:
@@ -53,7 +53,21 @@ class Messages::Facebook::MessageBuilder < Messages::Messenger::MessageBuilder
|
||||
end
|
||||
|
||||
def conversation
|
||||
@conversation ||= Conversation.find_by(conversation_params) || build_conversation
|
||||
@conversation ||= begin
|
||||
lock_to_single_conversation = @inbox.lock_to_single_conversation
|
||||
|
||||
if lock_to_single_conversation
|
||||
Conversation.find_by(conversation_params) || build_conversation
|
||||
else
|
||||
# If lock to single conversation is disabled, we will create a new conversation if previous conversation is resolved
|
||||
last_conversation = Conversation.where(conversation_params).order(created_at: :desc).first
|
||||
if last_conversation&.status == 'resolved'
|
||||
build_conversation
|
||||
else
|
||||
last_conversation
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def build_conversation
|
||||
|
||||
@@ -69,9 +69,23 @@ class Messages::Instagram::MessageBuilder < Messages::Messenger::MessageBuilder
|
||||
end
|
||||
|
||||
def conversation
|
||||
@conversation ||= Conversation.where(conversation_params).find_by(
|
||||
"additional_attributes ->> 'type' = 'instagram_direct_message'"
|
||||
) || build_conversation
|
||||
@conversation ||= begin
|
||||
lock_to_single_conversation = @inbox.lock_to_single_conversation
|
||||
|
||||
if lock_to_single_conversation
|
||||
Conversation.where(conversation_params).find_by(
|
||||
"additional_attributes ->> 'type' = 'instagram_direct_message'"
|
||||
) || build_conversation
|
||||
else
|
||||
# If lock to single conversation is disabled, we will create a new conversation if previous conversation is resolved
|
||||
last_conversation = Conversation.where(conversation_params).order(created_at: :desc).first
|
||||
if last_conversation&.status == 'resolved'
|
||||
build_conversation
|
||||
else
|
||||
last_conversation
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def message_content
|
||||
|
||||
Reference in New Issue
Block a user