Browse Source

FIX deal with gitea api response body bug

tags/v3.0.0
Jasder 5 years ago
parent
commit
e7662b66ce
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      app/services/gitea/client_service.rb

+ 3
- 1
app/services/gitea/client_service.rb View File

@@ -178,8 +178,10 @@ class Gitea::ClientService < ApplicationService
def get_body_by_status(status, body)
body, message =
case status
when 401 then [nil, "401"]
when 404 then [nil, "404"]
when 403 then [nil, "403"]
when 500 then [nil, "500"]
else
if body.present?
body = JSON.parse(body)
@@ -198,7 +200,7 @@ class Gitea::ClientService < ApplicationService
end

def fix_body(body)
return [body, nil] if body.is_a? Array
return [body, nil] if body.is_a?(Array) || body.is_a?(Hash)

body['message'].blank? ? [body, nil] : [nil, body['message']]
end


Loading…
Cancel
Save