Navigation Menu

Skip to content

Commit

Permalink
FIX: Send new topic Slack notifications to the correct thread
Browse files Browse the repository at this point in the history
This applies when topics are created using the slack transcript feature, and there is a rule configured with filter=thread
  • Loading branch information
davidtaylorhq committed Aug 14, 2020
1 parent d93fea8 commit bdca153
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/discourse_chat/provider/slack/slack_provider.rb
Expand Up @@ -112,6 +112,7 @@ def self.send_via_api(post, channel, message)
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
Expand Down
6 changes: 4 additions & 2 deletions spec/lib/discourse_chat/provider/slack/slack_provider_spec.rb
Expand Up @@ -120,15 +120,17 @@
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
)

rule = DiscourseChat::Rule.create(channel: @channel, filter: "thread")
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
Expand Down

0 comments on commit bdca153

Please sign in to comment.