| @@ -880,9 +880,9 @@ class ApplicationController < ActionController::Base | |||||
| }.to_json | }.to_json | ||||
| resp_body = Blockchain::InvokeBlockchainApi.call(params) | resp_body = Blockchain::InvokeBlockchainApi.call(params) | ||||
| if resp_body['status'] == 10 | if resp_body['status'] == 10 | ||||
| raise Error, resp_body['message'] | |||||
| raise ApplicationService::Error, resp_body['message'] | |||||
| elsif resp_body['status'] != 0 | elsif resp_body['status'] != 0 | ||||
| raise Error, "区块链接口请求失败." | |||||
| raise ApplicationService::Error, "区块链接口请求失败." | |||||
| end | end | ||||
| elsif activity_type == "issue_comment_create" | elsif activity_type == "issue_comment_create" | ||||
| @@ -951,9 +951,9 @@ class ApplicationController < ActionController::Base | |||||
| # 调用区块链接口 | # 调用区块链接口 | ||||
| resp_body = Blockchain::InvokeBlockchainApi.call(params) | resp_body = Blockchain::InvokeBlockchainApi.call(params) | ||||
| if resp_body['status'] == 10 | if resp_body['status'] == 10 | ||||
| raise Error, resp_body['message'] | |||||
| raise ApplicationService::Error, resp_body['message'] | |||||
| elsif resp_body['status'] != 0 | elsif resp_body['status'] != 0 | ||||
| raise Error, "区块链接口请求失败." | |||||
| raise ApplicationService::Error, "区块链接口请求失败." | |||||
| end | end | ||||
| elsif activity_type == "pull_request_create" | elsif activity_type == "pull_request_create" | ||||
| # 调用区块链接口 | # 调用区块链接口 | ||||
| @@ -989,9 +989,9 @@ class ApplicationController < ActionController::Base | |||||
| updated_at = model['updated_at'] | updated_at = model['updated_at'] | ||||
| # 查询pull request对应的commit信息 | # 查询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? | if commits.nil? | ||||
| raise Error, "区块链接口请求失败" # 获取pr中变更的commit信息失败 | |||||
| raise ApplicationService::Error, "区块链接口请求失败" # 获取pr中变更的commit信息失败 | |||||
| end | end | ||||
| commit_shas = [] | commit_shas = [] | ||||
| commits.each do |c| | commits.each do |c| | ||||
| @@ -1018,9 +1018,9 @@ class ApplicationController < ActionController::Base | |||||
| }.to_json | }.to_json | ||||
| resp_body = Blockchain::InvokeBlockchainApi.call(params) | resp_body = Blockchain::InvokeBlockchainApi.call(params) | ||||
| if resp_body['status'] == 9 | if resp_body['status'] == 9 | ||||
| raise Error, resp_body['message'] | |||||
| raise ApplicationService::Error, resp_body['message'] | |||||
| elsif resp_body['status'] != 0 | elsif resp_body['status'] != 0 | ||||
| raise Error, "区块链接口请求失败." | |||||
| raise ApplicationService::Error, "区块链接口请求失败." | |||||
| end | end | ||||
| elsif activity_type == "pull_request_merge" | elsif activity_type == "pull_request_merge" | ||||
| # 调用区块链接口 | # 调用区块链接口 | ||||
| @@ -1043,9 +1043,9 @@ class ApplicationController < ActionController::Base | |||||
| updated_at = model['updated_at'] | updated_at = model['updated_at'] | ||||
| # 查询pull request对应的commit信息 | # 查询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? | if commits.nil? | ||||
| raise Error, "区块链接口请求失败" # 获取pr中变更的commit信息失败 | |||||
| raise ApplicationService::Error, "区块链接口请求失败" # 获取pr中变更的commit信息失败 | |||||
| end | end | ||||
| commit_shas = [] | commit_shas = [] | ||||
| commits.each do |c| | commits.each do |c| | ||||
| @@ -1074,16 +1074,16 @@ class ApplicationController < ActionController::Base | |||||
| }.to_json | }.to_json | ||||
| resp_body = Blockchain::InvokeBlockchainApi.call(params) | resp_body = Blockchain::InvokeBlockchainApi.call(params) | ||||
| if resp_body['status'] == 9 | if resp_body['status'] == 9 | ||||
| raise Error, resp_body['message'] | |||||
| raise ApplicationService::Error, resp_body['message'] | |||||
| elsif resp_body['status'] != 0 | elsif resp_body['status'] != 0 | ||||
| raise Error, "区块链接口请求失败." | |||||
| raise ApplicationService::Error, "区块链接口请求失败." | |||||
| end | end | ||||
| # 将commit相关信息写入链上 | # 将commit相关信息写入链上 | ||||
| commit_shas.each do |commit_sha| | 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 = { | params = { | ||||
| "request-type": "upload commit info", | "request-type": "upload commit info", | ||||
| "commit_hash": commit_sha, | "commit_hash": commit_sha, | ||||
| @@ -1099,9 +1099,9 @@ class ApplicationController < ActionController::Base | |||||
| }.to_json | }.to_json | ||||
| resp_body = Blockchain::InvokeBlockchainApi.call(params) | resp_body = Blockchain::InvokeBlockchainApi.call(params) | ||||
| if resp_body['status'] == 7 | if resp_body['status'] == 7 | ||||
| raise Error, resp_body['message'] | |||||
| raise ApplicationService::Error, resp_body['message'] | |||||
| elsif resp_body['status'] != 0 | elsif resp_body['status'] != 0 | ||||
| raise Error, "区块链接口请求失败." | |||||
| raise ApplicationService::Error, "区块链接口请求失败." | |||||
| end | end | ||||
| end | end | ||||
| @@ -1145,9 +1145,9 @@ class ApplicationController < ActionController::Base | |||||
| }.to_json | }.to_json | ||||
| resp_body = Blockchain::InvokeBlockchainApi.call(params) | resp_body = Blockchain::InvokeBlockchainApi.call(params) | ||||
| if resp_body['status'] == 9 | if resp_body['status'] == 9 | ||||
| raise Error, resp_body['message'] | |||||
| raise ApplicationService::Error, resp_body['message'] | |||||
| elsif resp_body['status'] != 0 | elsif resp_body['status'] != 0 | ||||
| raise Error, "区块链接口请求失败." | |||||
| raise ApplicationService::Error, "区块链接口请求失败." | |||||
| end | end | ||||
| end | end | ||||
| end | end | ||||