fix: Create new slack thread if the thread identifier changes (#7702)

Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
This commit is contained in:
Muhsin Keloth
2023-08-11 14:19:49 +05:30
committed by GitHub
parent 84240e197a
commit cfe86d9c06
2 changed files with 47 additions and 1 deletions

View File

@@ -128,7 +128,7 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
end
def update_reference_id
return if conversation.identifier
return unless should_update_reference_id?
conversation.update!(identifier: @slack_message['ts'])
end
@@ -146,4 +146,12 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
def link_to_conversation
"<#{ENV.fetch('FRONTEND_URL', nil)}/app/accounts/#{conversation.account_id}/conversations/#{conversation.display_id}|Click here>"
end
# Determines whether the conversation identifier should be updated with the ts value.
# The identifier should be updated in the following cases:
# - If the conversation identifier is blank, it means a new conversation is being created.
# - If the thread_ts is blank, it means that the conversation was previously connected in a different channel.
def should_update_reference_id?
conversation.identifier.blank? || @slack_message['message']['thread_ts'].blank?
end
end