From 78abf3a817f14f39a535cfc2c04f470cf42a3f61 Mon Sep 17 00:00:00 2001 From: Ian Claxton Date: Thu, 6 Feb 2020 18:54:19 +0000 Subject: [PATCH] Having an option for setting SlackChatConfiguration.getConfiguration.asUser() when there is no username specified solves a number of issues. Using the default username TeamCity is fine if you have a user named teamcity or have some legacy config but for new configurations this is not working. Without this we are stuck in limbo where we are unable to use the new bot scopes with the plugin and only able to use legacy bots which unless asUser() is set has the default slack grey bot icon (which sucks). --- .../main/scala/com/fpd/teamcity/slack/SlackGateway.scala | 7 ++++++- .../src/main/scala/com/fpd/teamcity/slack/Strings.scala | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/slackIntegration-server/src/main/scala/com/fpd/teamcity/slack/SlackGateway.scala b/slackIntegration-server/src/main/scala/com/fpd/teamcity/slack/SlackGateway.scala index ac1850a..2bd2f3f 100644 --- a/slackIntegration-server/src/main/scala/com/fpd/teamcity/slack/SlackGateway.scala +++ b/slackIntegration-server/src/main/scala/com/fpd/teamcity/slack/SlackGateway.scala @@ -121,7 +121,12 @@ class SlackGateway(val configManager: ConfigManager, logger: Logger) { } private def channelChatConfiguration = - SlackChatConfiguration.getConfiguration.withName(configManager.senderName.getOrElse(Strings.channelMessageOwner)) + configManager.senderName match { + case Some(senderName) ⇒ + SlackChatConfiguration.getConfiguration.withName(senderName) + case _ ⇒ + SlackChatConfiguration.getConfiguration.asUser() + } private def sendMessageInternal(destination: Destination, message: SlackMessage): MessageSent = session match { case Some(x) ⇒ diff --git a/slackIntegration-server/src/main/scala/com/fpd/teamcity/slack/Strings.scala b/slackIntegration-server/src/main/scala/com/fpd/teamcity/slack/Strings.scala index c48c297..d821ced 100644 --- a/slackIntegration-server/src/main/scala/com/fpd/teamcity/slack/Strings.scala +++ b/slackIntegration-server/src/main/scala/com/fpd/teamcity/slack/Strings.scala @@ -6,7 +6,6 @@ object Strings { lazy val logCategory = "Slack Integration" def label: String = "Slack" def tabId: String = "Slack" - lazy val channelMessageOwner = "TeamCity" private def unableToCreateSessionByConfig(reason: String): String = s"Unable to create session by config: $reason"