FIX: Send new topic Slack notifications to the correct thread

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

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`
-             <!--SLACK_CHANNEL_ID=UIGNOREFORNOW;SLACK_TS=1501801629.052212-->
+             <!--SLACK_CHANNEL_ID=UIGNOREFORNOW;SLACK_TS=#{@ts}-->
         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

GitHub sha: bdca153a