Use generic ‘conversations’ API endpoint to enable transcripts for slack IMs and groups

This commit is contained in:
David Taylor 2018-04-08 02:27:49 +01:00
parent 180011c097
commit 427cfc2305
3 changed files with 7 additions and 7 deletions

View File

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

View File

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

View File

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