FIX: these are not spe and dont have response.parsed_body

This commit is contained in:
jjaffeux 2020-09-25 21:08:28 +02:00
parent d483f4ae5a
commit d5808f4e9a
4 changed files with 5 additions and 5 deletions

View File

@ -64,7 +64,7 @@ module DiscourseChat
if !response.kind_of?(Net::HTTPSuccess)
error_key = nil
begin
responseData = response.parsed_body
responseData = JSON.parse(response.body)
if responseData['errcode'] == "M_UNKNOWN_TOKEN"
error_key = 'chat_integration.provider.matrix.errors.unknown_token'
elsif responseData['errcode'] == "M_UNKNOWN"

View File

@ -125,7 +125,7 @@ module DiscourseChat::Provider::SlackProvider
raise ::DiscourseChat::ProviderError.new info: { request: uri, response_code: response.code, response_body: response.body }
end
json = response.parsed_body
json = JSON.parse(response.body)
unless json["ok"] == true
if json.key?("error") && (json["error"] == ('channel_not_found') || json["error"] == ('is_archived'))

View File

@ -208,7 +208,7 @@ module DiscourseChat::Provider::SlackProvider
req.set_form_data(token: SiteSetting.chat_integration_slack_access_token, limit: 200, cursor: cursor)
response = http.request(req)
return false unless response.kind_of? Net::HTTPSuccess
json = response.parsed_body
json = JSON.parse(response.body)
return false unless json['ok']
cursor = json['response_metadata']['next_cursor']
json['members'].each do |user|
@ -244,7 +244,7 @@ module DiscourseChat::Provider::SlackProvider
req.set_form_data(data)
response = http.request(req)
return false unless response.kind_of? Net::HTTPSuccess
json = response.parsed_body
json = JSON.parse(response.body)
return false unless json['ok']
raw_messages = json['messages']

View File

@ -44,7 +44,7 @@ module DiscourseChat
req.body = message.to_json
response = http.request(req)
responseData = response.parsed_body
responseData = JSON.parse(response.body)
responseData
end