FIX: Determine uncategorized category name using new core pattern

This commit is contained in:
David Taylor 2019-06-04 18:47:32 +01:00
parent 3c030c8fbf
commit f75903cae5
3 changed files with 12 additions and 6 deletions

View File

@ -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,
}

View File

@ -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
}

View File

@ -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
}