From 7e5dc5acc1fc6ea762ff51e00cbd430fb8191c5a Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 30 Sep 2019 13:27:35 +0100 Subject: [PATCH] FIX: Allow slash commands to set rules in private groups The Slack 'slash commands' API does not provide the user-friendly group name, so we must use the group ID. We could use the API to obtain the group name, but it would require adding additional scopes to the app. --- lib/discourse_chat/provider/slack/slack_command_controller.rb | 2 ++ lib/discourse_chat/provider/slack/slack_provider.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/discourse_chat/provider/slack/slack_command_controller.rb b/lib/discourse_chat/provider/slack/slack_command_controller.rb index edecda7..4fc905a 100644 --- a/lib/discourse_chat/provider/slack/slack_command_controller.rb +++ b/lib/discourse_chat/provider/slack/slack_command_controller.rb @@ -28,6 +28,8 @@ module DiscourseChat::Provider::SlackProvider case params[:channel_name] when 'directmessage' "@#{params[:user_name]}" + when 'privategroup' + params[:channel_id] else "##{params[:channel_name]}" end diff --git a/lib/discourse_chat/provider/slack/slack_provider.rb b/lib/discourse_chat/provider/slack/slack_provider.rb index 419e4dd..82f5f5a 100644 --- a/lib/discourse_chat/provider/slack/slack_provider.rb +++ b/lib/discourse_chat/provider/slack/slack_provider.rb @@ -6,7 +6,7 @@ module DiscourseChat::Provider::SlackProvider PROVIDER_ENABLED_SETTING = :chat_integration_slack_enabled CHANNEL_PARAMETERS = [ - { key: "identifier", regex: '^[@#]\S*$', unique: true } + { key: "identifier", regex: '^[@#]?\S*$', unique: true } ] def self.excerpt(post, max_length = SiteSetting.chat_integration_slack_excerpt_length)