新增:新版疑修上链操作
This commit is contained in:
parent
aba5de8bb8
commit
c9c16aef8d
|
@ -160,14 +160,16 @@ class IssuesController < ApplicationController
|
|||
# 新增时向grimoirelab推送事件
|
||||
IssueWebhookJob.set(wait: 5.seconds).perform_later(@issue.id)
|
||||
|
||||
# author: zxh
|
||||
# 扣除发起人的token
|
||||
if @issue.blockchain_token_num > 0
|
||||
Blockchain::CreateIssue.call(user_id: @issue.author_id, project_id: @issue.project_id, token_num: @issue.blockchain_token_num)
|
||||
end
|
||||
if Site.has_blockchain?
|
||||
# author: zxh
|
||||
# 扣除发起人的token
|
||||
if @issue.blockchain_token_num > 0
|
||||
Blockchain::CreateIssue.call(user_id: @issue.author_id, project_id: @issue.project_id, token_num: @issue.blockchain_token_num)
|
||||
end
|
||||
|
||||
# 调用上链API存证
|
||||
push_activity_2_blockchain("issue_create", @issue)
|
||||
# 调用上链API存证
|
||||
push_activity_2_blockchain("issue_create", @issue)
|
||||
end
|
||||
|
||||
render json: {status: 0, message: "创建成功", id: @issue.id}
|
||||
else
|
||||
|
|
|
@ -50,7 +50,7 @@ class JournalsController < ApplicationController
|
|||
|
||||
# author: zxh
|
||||
# 调用上链API
|
||||
push_activity_2_blockchain("issue_comment_create", journal)
|
||||
push_activity_2_blockchain("issue_comment_create", journal) if Site.has_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)
|
||||
push_activity_2_blockchain("pull_request_create", @pull_request) if Site.has_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)
|
||||
push_activity_2_blockchain("pull_request_refuse", @pull_request) if Site.has_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)
|
||||
push_activity_2_blockchain("pull_request_merge", @pull_request) if Site.has_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})
|
||||
Blockchain::FixIssue.call({user_id: author_id.to_s, project_id: project.id.to_s, token_num: token_num}) if Site.has_blockchain?
|
||||
end
|
||||
# update issue to state 5
|
||||
issue.update(status_id: 5)
|
||||
|
|
|
@ -30,6 +30,10 @@ class Site < ApplicationRecord
|
|||
self.common.where(key: 'notice').present?
|
||||
end
|
||||
|
||||
def self.has_blockchain?
|
||||
self.common.where(key: 'blockchain').present?
|
||||
end
|
||||
|
||||
private
|
||||
def self.set_add_menu!
|
||||
adds= [
|
||||
|
|
|
@ -59,8 +59,20 @@ 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 @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
|
||||
|
||||
push_activity_2_blockchain("issue_create", @created_issue)
|
||||
end
|
||||
|
||||
project.del_project_issue_cache_delete_count # 把缓存里存储项目删除issue的个数清除掉
|
||||
|
||||
# 新增时向grimoirelab推送事件
|
||||
IssueWebhookJob.set(wait: 5.seconds).perform_later(@created_issue.id)
|
||||
|
||||
# @信息发送
|
||||
AtmeService.call(current_user, @atme_receivers, @created_issue) unless receivers_login.blank?
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ 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?
|
||||
|
||||
# @信息发送
|
||||
AtmeService.call(current_user, @atme_receivers, @created_journal) unless receivers_login.blank?
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ class Api::V1::Projects::Pulls::Journals::CreateService < ApplicationService
|
|||
create_comment_journal
|
||||
end
|
||||
|
||||
push_activity_2_blockchain("issue_comment_create", @journal) if Site.has_blockchain?
|
||||
|
||||
journal
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue