From bdca153a0995d312a44f7d99ce4a28aa9ea424d0 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 14 Aug 2020 19:15:02 +0100 Subject: [PATCH] FIX: Send new topic Slack notifications to the correct thread This applies when topics are created using the slack transcript feature, and there is a rule configured with filter=thread --- lib/discourse_chat/provider/slack/slack_provider.rb | 1 + .../discourse_chat/provider/slack/slack_provider_spec.rb | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/discourse_chat/provider/slack/slack_provider.rb b/lib/discourse_chat/provider/slack/slack_provider.rb index 355c3a9..93bf9fd 100644 --- a/lib/discourse_chat/provider/slack/slack_provider.rb +++ b/lib/discourse_chat/provider/slack/slack_provider.rb @@ -112,6 +112,7 @@ module DiscourseChat::Provider::SlackProvider if message.key?(:thread_ts) data[:thread_ts] = message[:thread_ts] elsif match = slack_thread_regex.match(post.raw) + data[:thread_ts] = match.captures[1] post.topic.slack_thread_id = match.captures[1] post.topic.save_custom_fields end diff --git a/spec/lib/discourse_chat/provider/slack/slack_provider_spec.rb b/spec/lib/discourse_chat/provider/slack/slack_provider_spec.rb index 38d9b8b..d3cdc03 100644 --- a/spec/lib/discourse_chat/provider/slack/slack_provider_spec.rb +++ b/spec/lib/discourse_chat/provider/slack/slack_provider_spec.rb @@ -120,7 +120,7 @@ RSpec.describe DiscourseChat::Provider::SlackProvider do it 'recognizes slack thread ts in comment' do post.update!(cooked: "cooked", raw: <<~RAW My fingers are typing words that improve `raw_quality` - + RAW ) @@ -128,7 +128,9 @@ RSpec.describe DiscourseChat::Provider::SlackProvider do post.topic.slack_thread_id = nil described_class.trigger_notification(post, chan1, rule) - expect(post.topic.slack_thread_id).to eq('1501801629.052212') + expect(post.topic.slack_thread_id).to eq(@ts) + + expect(@thread_stub).to have_been_requested.times(1) end it 'handles errors correctly' do