FEATURE: support for slack custom username (#22)
* FEATURE: support for slack custom username * make slack username setting backwards compatible * fix slack username behavior when empty string
This commit is contained in:
parent
df44beb9a3
commit
695d56a3dd
|
@ -7,6 +7,7 @@ en:
|
|||
#######################################
|
||||
########## SLACK SETTINGS #############
|
||||
#######################################
|
||||
chat_integration_slack_username: "Bot's username to post to slack with"
|
||||
chat_integration_slack_enabled: 'Enable the slack chat-integration provider'
|
||||
chat_integration_slack_access_token: 'OAuth Access Token for authenticating with Slack'
|
||||
chat_integration_slack_incoming_webhook_token: 'The verification token used to authenticate incoming requests'
|
||||
|
|
|
@ -10,6 +10,8 @@ chat_integration:
|
|||
#######################################
|
||||
########## SLACK SETTINGS #############
|
||||
#######################################
|
||||
chat_integration_slack_username:
|
||||
default: ''
|
||||
chat_integration_slack_enabled:
|
||||
default: false
|
||||
validator: "ChatIntegrationSlackEnabledSettingValidator"
|
||||
|
|
|
@ -42,9 +42,16 @@ module DiscourseChat::Provider::SlackProvider
|
|||
"#{Discourse.base_url}#{url}"
|
||||
end
|
||||
|
||||
slack_username =
|
||||
if SiteSetting.chat_integration_slack_username.present?
|
||||
SiteSetting.chat_integration_slack_username
|
||||
else
|
||||
SiteSetting.title || "Discourse"
|
||||
end
|
||||
|
||||
message = {
|
||||
channel: channel,
|
||||
username: SiteSetting.title || "Discourse",
|
||||
username: slack_username,
|
||||
icon_url: icon_url,
|
||||
attachments: []
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue