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
This commit is contained in:
David Taylor 2020-08-14 19:15:02 +01:00
parent d93fea8206
commit bdca153a09
No known key found for this signature in database
GPG Key ID: 46904C18B1D3F434
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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