新增:上链需要项目开启区块链机制
This commit is contained in:
parent
a291641505
commit
3e0df7c1b9
|
@ -160,7 +160,7 @@ class IssuesController < ApplicationController
|
|||
# 新增时向grimoirelab推送事件
|
||||
IssueWebhookJob.set(wait: 5.seconds).perform_later(@issue.id)
|
||||
|
||||
if Site.has_blockchain?
|
||||
if Site.has_blockchain? && @project.use_blockchain
|
||||
# author: zxh
|
||||
# 扣除发起人的token
|
||||
if @issue.blockchain_token_num > 0
|
||||
|
|
|
@ -50,7 +50,7 @@ class JournalsController < ApplicationController
|
|||
|
||||
# author: zxh
|
||||
# 调用上链API
|
||||
push_activity_2_blockchain("issue_comment_create", journal) if Site.has_blockchain?
|
||||
push_activity_2_blockchain("issue_comment_create", journal) if Site.has_blockchain? && @project.use_blockchain
|
||||
|
||||
render :json => { status: 0, message: "评论成功", id: journal.id}
|
||||
else
|
||||
|
|
|
@ -77,7 +77,7 @@ class PullRequestsController < ApplicationController
|
|||
|
||||
# author: zxh
|
||||
# 调用上链API
|
||||
push_activity_2_blockchain("pull_request_create", @pull_request) if Site.has_blockchain?
|
||||
push_activity_2_blockchain("pull_request_create", @pull_request) if Site.has_blockchain? && @project.use_blockchain
|
||||
|
||||
else
|
||||
render_error("create pull request error: #{@gitea_pull_request[:status]}")
|
||||
|
@ -169,7 +169,7 @@ class PullRequestsController < ApplicationController
|
|||
colsed = PullRequests::CloseService.call(@owner, @repository, @pull_request, current_user)
|
||||
# author: zxh
|
||||
# 调用上链API
|
||||
push_activity_2_blockchain("pull_request_refuse", @pull_request) if Site.has_blockchain?
|
||||
push_activity_2_blockchain("pull_request_refuse", @pull_request) if Site.has_blockchain? && @project.use_blockchain
|
||||
|
||||
if colsed === true
|
||||
@pull_request.project_trends.create!(user: current_user, project: @project,action_type: ProjectTrend::CLOSE)
|
||||
|
@ -223,7 +223,7 @@ class PullRequestsController < ApplicationController
|
|||
|
||||
# author: zxh
|
||||
# 调用上链API
|
||||
push_activity_2_blockchain("pull_request_merge", @pull_request) if Site.has_blockchain?
|
||||
push_activity_2_blockchain("pull_request_merge", @pull_request) if Site.has_blockchain? && @project.use_blockchain
|
||||
|
||||
# 查看是否fix了相关issue,如果fix就转账
|
||||
@pull_request.attached_issues.each do |issue|
|
||||
|
@ -231,7 +231,7 @@ class PullRequestsController < ApplicationController
|
|||
token_num = token_num.nil? ? 0 : token_num
|
||||
author_id = @pull_request.user_id
|
||||
if token_num > 0
|
||||
Blockchain::FixIssue.call({user_id: author_id.to_s, project_id: project.id.to_s, token_num: token_num}) if Site.has_blockchain?
|
||||
Blockchain::FixIssue.call({user_id: author_id.to_s, project_id: project.id.to_s, token_num: token_num}) if Site.has_blockchain? && @project.use_blockchain
|
||||
end
|
||||
# update issue to state 5
|
||||
issue.update(status_id: 5)
|
||||
|
|
|
@ -60,7 +60,7 @@ class Api::V1::Issues::CreateService < ApplicationService
|
|||
@created_issue.issue_tags_value = @issue_tags.order("id asc").pluck(:id).join(",") unless issue_tag_ids.blank?
|
||||
@created_issue.save!
|
||||
|
||||
if Site.has_blockchain?
|
||||
if Site.has_blockchain? && @project.use_blockchain
|
||||
if @created_issue.blockchain_token_num > 0
|
||||
Blockchain::CreateIssue.call(user_id: @created_issue.author_id, project_id: @created_issue.project_id, token_num: @created_issue.blockchain_token_num)
|
||||
end
|
||||
|
|
|
@ -39,7 +39,7 @@ class Api::V1::Issues::Journals::CreateService < ApplicationService
|
|||
@created_journal.save!
|
||||
@issue.save!
|
||||
|
||||
push_activity_2_blockchain("issue_comment_create", @created_journal) if Site.has_blockchain?
|
||||
push_activity_2_blockchain("issue_comment_create", @created_journal) if Site.has_blockchain? && @project.use_blockchain
|
||||
|
||||
# @信息发送
|
||||
AtmeService.call(current_user, @atme_receivers, @created_journal) unless receivers_login.blank?
|
||||
|
|
|
@ -30,7 +30,7 @@ class Api::V1::Projects::Pulls::Journals::CreateService < ApplicationService
|
|||
create_comment_journal
|
||||
end
|
||||
|
||||
push_activity_2_blockchain("issue_comment_create", @journal) if Site.has_blockchain?
|
||||
push_activity_2_blockchain("issue_comment_create", @journal) if Site.has_blockchain? && @project.use_blockchain
|
||||
|
||||
journal
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue