From 00eda17c2c42144b73b2e4517196cfbb825de31a Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 9 Mar 2023 15:37:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E8=AF=B7=E6=B1=82gi?= =?UTF-8?q?tea=E6=8E=A5=E5=8F=A3=E9=9C=80=E8=8E=B7=E5=8F=96=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E7=94=A8=E6=88=B7token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 36 +++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f98c3c456..31d56f9e3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -880,9 +880,9 @@ class ApplicationController < ActionController::Base }.to_json resp_body = Blockchain::InvokeBlockchainApi.call(params) if resp_body['status'] == 10 - raise Error, resp_body['message'] + raise ApplicationService::Error, resp_body['message'] elsif resp_body['status'] != 0 - raise Error, "区块链接口请求失败." + raise ApplicationService::Error, "区块链接口请求失败." end elsif activity_type == "issue_comment_create" @@ -951,9 +951,9 @@ class ApplicationController < ActionController::Base # 调用区块链接口 resp_body = Blockchain::InvokeBlockchainApi.call(params) if resp_body['status'] == 10 - raise Error, resp_body['message'] + raise ApplicationService::Error, resp_body['message'] elsif resp_body['status'] != 0 - raise Error, "区块链接口请求失败." + raise ApplicationService::Error, "区块链接口请求失败." end elsif activity_type == "pull_request_create" # 调用区块链接口 @@ -989,9 +989,9 @@ class ApplicationController < ActionController::Base updated_at = model['updated_at'] # 查询pull request对应的commit信息 - commits = Gitea::PullRequest::CommitsService.call(ownername, identifier, model['gitea_number']) + commits = Gitea::PullRequest::CommitsService.call(ownername, identifier, model['gitea_number'], current_user&.gitea_token) if commits.nil? - raise Error, "区块链接口请求失败" # 获取pr中变更的commit信息失败 + raise ApplicationService::Error, "区块链接口请求失败" # 获取pr中变更的commit信息失败 end commit_shas = [] commits.each do |c| @@ -1018,9 +1018,9 @@ class ApplicationController < ActionController::Base }.to_json resp_body = Blockchain::InvokeBlockchainApi.call(params) if resp_body['status'] == 9 - raise Error, resp_body['message'] + raise ApplicationService::Error, resp_body['message'] elsif resp_body['status'] != 0 - raise Error, "区块链接口请求失败." + raise ApplicationService::Error, "区块链接口请求失败." end elsif activity_type == "pull_request_merge" # 调用区块链接口 @@ -1043,9 +1043,9 @@ class ApplicationController < ActionController::Base updated_at = model['updated_at'] # 查询pull request对应的commit信息 - commits = Gitea::PullRequest::CommitsService.call(ownername, identifier, model['gitea_number']) + commits = Gitea::PullRequest::CommitsService.call(ownername, identifier, model['gitea_number'], current_user&.gitea_token) if commits.nil? - raise Error, "区块链接口请求失败" # 获取pr中变更的commit信息失败 + raise ApplicationService::Error, "区块链接口请求失败" # 获取pr中变更的commit信息失败 end commit_shas = [] commits.each do |c| @@ -1074,16 +1074,16 @@ class ApplicationController < ActionController::Base }.to_json resp_body = Blockchain::InvokeBlockchainApi.call(params) if resp_body['status'] == 9 - raise Error, resp_body['message'] + raise ApplicationService::Error, resp_body['message'] elsif resp_body['status'] != 0 - raise Error, "区块链接口请求失败." + raise ApplicationService::Error, "区块链接口请求失败." end # 将commit相关信息写入链上 commit_shas.each do |commit_sha| - commit_diff = Gitea::Commit::DiffService.call(ownername, identifier, commit_sha, owner['gitea_token']) - commit = Gitea::Commit::InfoService.call(ownername, identifier, commit_sha, owner['gitea_token']) + commit_diff = Gitea::Commit::DiffService.call(ownername, identifier, commit_sha, owner['gitea_token'], current_user&.gitea_token) + commit = Gitea::Commit::InfoService.call(ownername, identifier, commit_sha, owner['gitea_token'], current_user&.gitea_token) params = { "request-type": "upload commit info", "commit_hash": commit_sha, @@ -1099,9 +1099,9 @@ class ApplicationController < ActionController::Base }.to_json resp_body = Blockchain::InvokeBlockchainApi.call(params) if resp_body['status'] == 7 - raise Error, resp_body['message'] + raise ApplicationService::Error, resp_body['message'] elsif resp_body['status'] != 0 - raise Error, "区块链接口请求失败." + raise ApplicationService::Error, "区块链接口请求失败." end end @@ -1145,9 +1145,9 @@ class ApplicationController < ActionController::Base }.to_json resp_body = Blockchain::InvokeBlockchainApi.call(params) if resp_body['status'] == 9 - raise Error, resp_body['message'] + raise ApplicationService::Error, resp_body['message'] elsif resp_body['status'] != 0 - raise Error, "区块链接口请求失败." + raise ApplicationService::Error, "区块链接口请求失败." end end end