diff --git a/lib/discourse_chat/provider/mattermost/mattermost_provider.rb b/lib/discourse_chat/provider/mattermost/mattermost_provider.rb index 42c7eab..724b068 100644 --- a/lib/discourse_chat/provider/mattermost/mattermost_provider.rb +++ b/lib/discourse_chat/provider/mattermost/mattermost_provider.rb @@ -41,7 +41,9 @@ module DiscourseChat topic = post.topic category = '' - if topic.category + if topic.category&.uncategorized? + category = "[#{I18n.t('uncategorized_category_name')}]" + elsif topic.category category = (topic.category.parent_category) ? "[#{topic.category.parent_category.name}/#{topic.category.name}]" : "[#{topic.category.name}]" end @@ -65,7 +67,7 @@ module DiscourseChat author_icon: post.user.small_avatar_url, color: topic.category ? "##{topic.category.color}" : nil, text: post.excerpt(SiteSetting.chat_integration_mattermost_excerpt_length, text_entities: true, strip_links: true, remap_emoji: true), - title: "#{topic.title} #{(category == '[uncategorized]') ? '' : category} #{topic.tags.present? ? topic.tags.map(&:name).join(', ') : ''}", + title: "#{topic.title} #{category} #{topic.tags.present? ? topic.tags.map(&:name).join(', ') : ''}", title_link: post.full_url, } diff --git a/lib/discourse_chat/provider/rocketchat/rocketchat_provider.rb b/lib/discourse_chat/provider/rocketchat/rocketchat_provider.rb index b854a8e..82a3e6c 100644 --- a/lib/discourse_chat/provider/rocketchat/rocketchat_provider.rb +++ b/lib/discourse_chat/provider/rocketchat/rocketchat_provider.rb @@ -20,7 +20,9 @@ module DiscourseChat::Provider::RocketchatProvider topic = post.topic category = '' - if topic.category + if topic.category&.uncategorized? + category = "[#{I18n.t('uncategorized_category_name')}]" + elsif topic.category category = (topic.category.parent_category) ? "[#{topic.category.parent_category.name}/#{topic.category.name}]" : "[#{topic.category.name}]" end @@ -36,7 +38,7 @@ module DiscourseChat::Provider::RocketchatProvider color: topic.category ? "##{topic.category.color}" : nil, text: post.excerpt(SiteSetting.chat_integration_rocketchat_excerpt_length, text_entities: true, strip_links: true, remap_emoji: true), mrkdwn_in: ["text"], - title: "#{topic.title} #{(category == '[uncategorized]') ? '' : category} #{topic.tags.present? ? topic.tags.map(&:name).join(', ') : ''}", + title: "#{topic.title} #{category} #{topic.tags.present? ? topic.tags.map(&:name).join(', ') : ''}", title_link: post.full_url } diff --git a/lib/discourse_chat/provider/slack/slack_provider.rb b/lib/discourse_chat/provider/slack/slack_provider.rb index ee672a3..651e4cb 100644 --- a/lib/discourse_chat/provider/slack/slack_provider.rb +++ b/lib/discourse_chat/provider/slack/slack_provider.rb @@ -29,7 +29,9 @@ module DiscourseChat::Provider::SlackProvider topic = post.topic category = '' - if topic.category + if topic.category&.uncategorized? + category = "[#{I18n.t('uncategorized_category_name')}]" + elsif topic.category category = (topic.category.parent_category) ? "[#{topic.category.parent_category.name}/#{topic.category.name}]" : "[#{topic.category.name}]" end @@ -54,7 +56,7 @@ module DiscourseChat::Provider::SlackProvider color: topic.category ? "##{topic.category.color}" : nil, text: excerpt(post), mrkdwn_in: ["text"], - title: "#{topic.title} #{(category == '[uncategorized]') ? '' : category} #{topic.tags.present? ? topic.tags.map(&:name).join(', ') : ''}", + title: "#{topic.title} #{category} #{topic.tags.present? ? topic.tags.map(&:name).join(', ') : ''}", title_link: post.full_url, thumb_url: post.full_url }