Add support for new upload site settings.

44391ee8ab
This commit is contained in:
Guo Xiang Tan 2018-11-14 15:17:44 +08:00
parent 1b8d06c57c
commit 2b357b2dfe
4 changed files with 13 additions and 11 deletions

View File

@ -41,10 +41,10 @@ module DiscourseChat
)
icon_url =
if !SiteSetting.chat_integration_hipchat_icon_url.blank?
if SiteSetting.chat_integration_hipchat_icon_url.present?
UrlHelper.absolute(SiteSetting.chat_integration_hipchat_icon_url)
elsif !SiteSetting.logo_small_url.blank?
UrlHelper.absolute(SiteSetting.logo_small_url)
elsif (url = (SiteSetting.try(:site_logo_small_url) || SiteSetting.logo_small_url)).present?
UrlHelper.absolute(url)
end
message = {

View File

@ -44,10 +44,10 @@ module DiscourseChat
end
icon_url =
if !SiteSetting.chat_integration_mattermost_icon_url.blank?
if SiteSetting.chat_integration_mattermost_icon_url.present?
UrlHelper.absolute(SiteSetting.chat_integration_mattermost_icon_url)
elsif !SiteSetting.logo_small_url.blank?
UrlHelper.absolute(SiteSetting.logo_small_url)
elsif (url = (SiteSetting.try(:site_logo_small_url) || SiteSetting.logo_small_url)).present?
UrlHelper.absolute(url)
end
message = {

View File

@ -32,10 +32,10 @@ module DiscourseChat::Provider::SlackProvider
end
icon_url =
if !SiteSetting.chat_integration_slack_icon_url.blank?
if SiteSetting.chat_integration_slack_icon_url.present?
"#{Discourse.base_url}#{SiteSetting.chat_integration_slack_icon_url}"
elsif !SiteSetting.logo_small_url.blank?
"#{Discourse.base_url}#{SiteSetting.logo_small_url}"
elsif (url = (SiteSetting.try(:site_logo_small_url) || SiteSetting.logo_small_url)).present?
"#{Discourse.base_url}#{url}"
end
message = {

View File

@ -4,10 +4,12 @@ RSpec.describe DiscourseChat::Provider::MattermostProvider do
let(:post) { Fabricate(:post) }
describe '.trigger_notifications' do
let(:upload) { Fabricate(:upload) }
before do
SiteSetting.chat_integration_mattermost_enabled = true
SiteSetting.chat_integration_mattermost_webhook_url = "https://mattermost.blah/hook/abcd"
SiteSetting.logo_small_url = "https://some_small_logo"
SiteSetting.logo_small = upload
end
let(:chan1) { DiscourseChat::Channel.create!(provider: 'mattermost', data: { identifier: "#awesomechannel" }) }
@ -21,7 +23,7 @@ RSpec.describe DiscourseChat::Provider::MattermostProvider do
describe 'when mattermost icon is not configured' do
it 'defaults to the right icon' do
message = described_class.mattermost_message(post, chan1)
expect(message[:icon_url]).to eq(SiteSetting.logo_small_url)
expect(message[:icon_url]).to eq(UrlHelper.absolute(upload.url))
end
end