DEV: s/JSON.parse(response.body)/response.parsed_body

DEV: s/JSON.parse(response.body)/response.parsed_body

diff --git a/lib/discourse_chat/provider/matrix/matrix_provider.rb b/lib/discourse_chat/provider/matrix/matrix_provider.rb
index c70af25..d051a0f 100644
--- a/lib/discourse_chat/provider/matrix/matrix_provider.rb
+++ b/lib/discourse_chat/provider/matrix/matrix_provider.rb
@@ -64,7 +64,7 @@ module DiscourseChat
         if !response.kind_of?(Net::HTTPSuccess)
           error_key = nil
           begin
-            responseData = JSON.parse(response.body)
+            responseData = response.parsed_body
             if responseData['errcode'] == "M_UNKNOWN_TOKEN"
               error_key = 'chat_integration.provider.matrix.errors.unknown_token'
             elsif responseData['errcode'] == "M_UNKNOWN"
diff --git a/lib/discourse_chat/provider/slack/slack_provider.rb b/lib/discourse_chat/provider/slack/slack_provider.rb
index 93bf9fd..f30eda5 100644
--- a/lib/discourse_chat/provider/slack/slack_provider.rb
+++ b/lib/discourse_chat/provider/slack/slack_provider.rb
@@ -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 = JSON.parse(response.body)
+    json = response.parsed_body
 
     unless json["ok"] == true
       if json.key?("error") && (json["error"] == ('channel_not_found') || json["error"] == ('is_archived'))
diff --git a/lib/discourse_chat/provider/slack/slack_transcript.rb b/lib/discourse_chat/provider/slack/slack_transcript.rb
index 803a01f..ef6be10 100644
--- a/lib/discourse_chat/provider/slack/slack_transcript.rb
+++ b/lib/discourse_chat/provider/slack/slack_transcript.rb
@@ -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 = JSON.parse(response.body)
+        json = response.parsed_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 = JSON.parse(response.body)
+      json = response.parsed_body
       return false unless json['ok']
 
       raw_messages = json['messages']
diff --git a/lib/discourse_chat/provider/telegram/telegram_provider.rb b/lib/discourse_chat/provider/telegram/telegram_provider.rb
index c8d4d7e..9072db5 100644
--- a/lib/discourse_chat/provider/telegram/telegram_provider.rb
+++ b/lib/discourse_chat/provider/telegram/telegram_provider.rb
@@ -44,7 +44,7 @@ module DiscourseChat
         req.body = message.to_json
         response = http.request(req)
 
-        responseData = JSON.parse(response.body)
+        responseData = response.parsed_body
 
         responseData
       end
diff --git a/spec/lib/discourse_chat/provider/mattermost/mattermost_command_controller_spec.rb b/spec/lib/discourse_chat/provider/mattermost/mattermost_command_controller_spec.rb
index 075bd73..5424155 100644
--- a/spec/lib/discourse_chat/provider/mattermost/mattermost_command_controller_spec.rb
+++ b/spec/lib/discourse_chat/provider/mattermost/mattermost_command_controller_spec.rb
@@ -84,7 +84,7 @@ describe 'Mattermost Command Controller', type: :request do
             token: token
           }
 
-          json = JSON.parse(response.body)
+          json = response.parsed_body
 
           expect(json["text"]).to eq(I18n.t("chat_integration.provider.mattermost.create.created"))
 
@@ -103,7 +103,7 @@ describe 'Mattermost Command Controller', type: :request do
               token: token
             }
 
-            json = JSON.parse(response.body)
+            json = response.parsed_body
 
             expect(json["text"]).to eq(I18n.t("chat_integration.provider.mattermost.create.created"))
 
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 69cbd55..9c4cb74 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
@@ -65,7 +65,7 @@ describe 'Slack Command Controller', type: :request do
         }
 
         expect(response.status).to eq(200)
-        expect(JSON.parse(response.body)["text"]).to be_present
+        expect(response.parsed_body["text"]).to be_present
       end
     end
 
@@ -98,7 +98,7 @@ describe 'Slack Command Controller', type: :request do
             token: token
           }
 
-          json = JSON.parse(response.body)
+          json = response.parsed_body
 
           expect(json["text"]).to eq(I18n.t("chat_integration.provider.slack.create.created"))
 
@@ -117,7 +117,7 @@ describe 'Slack Command Controller', type: :request do
               token: token
             }
 
-            json = JSON.parse(response.body)
+            json = response.parsed_body
 
             expect(json["text"]).to eq(I18n.t("chat_integration.provider.slack.create.created"))
 
@@ -317,7 +317,7 @@ describe 'Slack Command Controller', type: :request do
             token: token
           }
 
-          json = JSON.parse(response.body)
+          json = response.parsed_body
 
           expect(json["text"]).to include(I18n.t("chat_integration.provider.slack.transcript.loading"))
         end
@@ -333,7 +333,7 @@ describe 'Slack Command Controller', type: :request do
             token: token
           }
 
-          json = JSON.parse(response.body)
+          json = response.parsed_body
 
           expect(json["text"]).to include(I18n.t("chat_integration.provider.slack.transcript.api_required"))
         end
diff --git a/spec/requests/chat_controller_spec.rb b/spec/requests/chat_controller_spec.rb
index 69f5fd4..e19e38a 100644
--- a/spec/requests/chat_controller_spec.rb
+++ b/spec/requests/chat_controller_spec.rb
@@ -49,7 +49,7 @@ describe 'Chat Controller', type: :request do
 
         expect(response.status).to eq(200)
 
-        json = JSON.parse(response.body)
+        json = response.parsed_body
 
         expect(json['providers'].size).to eq(2)
 
@@ -76,8 +76,6 @@ describe 'Chat Controller', type: :request do
         }
 
         expect(response.status).to eq(200)
-
-        JSON.parse(response.body)
       end
 
       it 'should fail for invalid channel' do
@@ -110,7 +108,7 @@ describe 'Chat Controller', type: :request do
 
         expect(response.status).to eq(200)
 
-        channels = JSON.parse(response.body)['channels']
+        channels = response.parsed_body['channels']
 
         expect(channels.count).to eq(1)
 

GitHub sha: d483f4ae