feat: Change slack bot and activity message appearance (#8349)

This commit is contained in:
Muhsin Keloth
2023-11-16 12:59:52 +05:30
committed by GitHub
parent 5f6e974531
commit 5f503b1a57
4 changed files with 35 additions and 5 deletions

View File

@@ -44,7 +44,7 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
def message_content
private_indicator = message.private? ? 'private: ' : ''
sanitized_content = ActionView::Base.full_sanitizer.sanitize(message_text)
sanitized_content = ActionView::Base.full_sanitizer.sanitize(format_message_content)
if conversation.identifier.present?
"#{private_indicator}#{sanitized_content}"
@@ -53,6 +53,10 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
end
end
def format_message_content
message.message_type == 'activity' ? "_#{message_text}_" : message_text
end
def message_text
if message.content.present?
message.content.gsub(MENTION_REGEX, '\1')
@@ -79,7 +83,7 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
end
def avatar_url(sender)
sender_type = sender.instance_of?(Contact) ? 'contact' : 'user'
sender_type = sender_type(sender).downcase
blob_key = sender&.avatar&.attached? ? sender.avatar.blob.key : nil
generate_url(sender_type, blob_key)
end
@@ -137,7 +141,15 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
end
def sender_type(sender)
sender.instance_of?(Contact) ? 'Contact' : 'Agent'
if sender.instance_of?(Contact)
'Contact'
elsif message.message_type == 'template' && sender.nil?
'Bot'
elsif message.message_type == 'activity' && sender.nil?
'System'
else
'Agent'
end
end
def update_reference_id