From 427cfc230564828dc2dc913e05adeee634576e1d Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 8 Apr 2018 02:27:49 +0100 Subject: [PATCH] =?UTF-8?q?Use=20generic=20=E2=80=98conversations=E2=80=99?= =?UTF-8?q?=20API=20endpoint=20to=20enable=20transcripts=20for=20slack=20I?= =?UTF-8?q?Ms=20and=20groups?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/discourse_chat/provider/slack/slack_transcript.rb | 4 ++-- .../provider/slack/slack_command_controller_spec.rb | 2 +- .../provider/slack/slack_transcript_spec.rb | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/discourse_chat/provider/slack/slack_transcript.rb b/lib/discourse_chat/provider/slack/slack_transcript.rb index f24c23d..23dd610 100644 --- a/lib/discourse_chat/provider/slack/slack_transcript.rb +++ b/lib/discourse_chat/provider/slack/slack_transcript.rb @@ -201,12 +201,12 @@ module DiscourseChat::Provider::SlackProvider http = Net::HTTP.new("slack.com", 443) http.use_ssl = true - req = Net::HTTP::Post.new(URI('https://slack.com/api/channels.history')) + req = Net::HTTP::Post.new(URI('https://slack.com/api/conversations.history')) data = { token: SiteSetting.chat_integration_slack_access_token, channel: @channel_id, - count: count + limit: count } req.set_form_data(data) diff --git a/spec/lib/discourse_chat/provider/slack/slack_command_controller_spec.rb b/spec/lib/discourse_chat/provider/slack/slack_command_controller_spec.rb index 1c2def9..f116879 100644 --- a/spec/lib/discourse_chat/provider/slack/slack_command_controller_spec.rb +++ b/spec/lib/discourse_chat/provider/slack/slack_command_controller_spec.rb @@ -196,7 +196,7 @@ describe 'Slack Command Controller', type: :request do context "with valid slack responses" do before do stub_request(:post, "https://slack.com/api/users.list").to_return(body: '{"ok":true,"members":[{"id":"U5Z773QLS","name":"david","profile":{"icon_24":"https://example.com/avatar"}}]}') - stub_request(:post, "https://slack.com/api/channels.history").to_return(body: { ok: true, messages: messages_fixture }.to_json) + stub_request(:post, "https://slack.com/api/conversations.history").to_return(body: { ok: true, messages: messages_fixture }.to_json) end it 'generates the transcript UI properly' do diff --git a/spec/lib/discourse_chat/provider/slack/slack_transcript_spec.rb b/spec/lib/discourse_chat/provider/slack/slack_transcript_spec.rb index 0cf262f..86ad694 100644 --- a/spec/lib/discourse_chat/provider/slack/slack_transcript_spec.rb +++ b/spec/lib/discourse_chat/provider/slack/slack_transcript_spec.rb @@ -105,7 +105,7 @@ RSpec.describe DiscourseChat::Provider::SlackProvider::SlackTranscript do describe 'loading history' do it 'loads messages correctly' do - stub_request(:post, "https://slack.com/api/channels.history") + stub_request(:post, "https://slack.com/api/conversations.history") .with(body: hash_including(token: "abcde", channel: 'G1234')) .to_return(status: 200, body: { ok: true, messages: messages_fixture }.to_json) @@ -113,14 +113,14 @@ RSpec.describe DiscourseChat::Provider::SlackProvider::SlackTranscript do end it 'handles failed connection' do - stub_request(:post, "https://slack.com/api/channels.history") + stub_request(:post, "https://slack.com/api/conversations.history") .to_return(status: 500, body: {}.to_json) expect(transcript.load_chat_history).to be_falsey end it 'handles slack failure' do - stub_request(:post, "https://slack.com/api/channels.history") + stub_request(:post, "https://slack.com/api/conversations.history") .to_return(status: 200, body: { ok: false }.to_json) expect(transcript.load_chat_history).to be_falsey @@ -129,7 +129,7 @@ RSpec.describe DiscourseChat::Provider::SlackProvider::SlackTranscript do context 'with loaded messages' do before do - stub_request(:post, "https://slack.com/api/channels.history") + stub_request(:post, "https://slack.com/api/conversations.history") .with(body: hash_including(token: "abcde", channel: 'G1234')) .to_return(status: 200, body: { ok: true, messages: messages_fixture }.to_json) transcript.load_chat_history