mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-20 13:05:16 +00:00
feat: change bot and system message appearnce
This commit is contained in:
@@ -38,7 +38,7 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
|
|||||||
|
|
||||||
def message_content
|
def message_content
|
||||||
private_indicator = message.private? ? 'private: ' : ''
|
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?
|
if conversation.identifier.present?
|
||||||
"#{private_indicator}#{sanitized_content}"
|
"#{private_indicator}#{sanitized_content}"
|
||||||
@@ -47,6 +47,10 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format_message_content
|
||||||
|
message.message_type == 'activity' ? "_#{message_text}_" : message_text
|
||||||
|
end
|
||||||
|
|
||||||
def message_text
|
def message_text
|
||||||
if message.content.present?
|
if message.content.present?
|
||||||
message.content.gsub(MENTION_REGEX, '\1')
|
message.content.gsub(MENTION_REGEX, '\1')
|
||||||
@@ -73,7 +77,7 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def avatar_url(sender)
|
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
|
blob_key = sender&.avatar&.attached? ? sender.avatar.blob.key : nil
|
||||||
generate_url(sender_type, blob_key)
|
generate_url(sender_type, blob_key)
|
||||||
end
|
end
|
||||||
@@ -130,7 +134,15 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sender_type(sender)
|
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
|
end
|
||||||
|
|
||||||
def update_reference_id
|
def update_reference_id
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
BIN
public/integrations/slack/bot.png
Normal file
BIN
public/integrations/slack/bot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
Reference in New Issue
Block a user