forked from Gitlink/forgeplus
修改token为任意可输入的值,不与链上个人余额相关的
This commit is contained in:
parent
83d516da04
commit
bc2504e25a
|
@ -106,18 +106,6 @@ class IssuesController < ApplicationController
|
|||
normal_status(-1, "标题不能超过255个字符")
|
||||
elsif (params[:issue_type].to_s == "2")
|
||||
return normal_status(-1, "悬赏的奖金必须大于0") if params[:token].to_i == 0
|
||||
#查看当前用户的积分
|
||||
query_params = {
|
||||
type: "query",
|
||||
chain_params: {
|
||||
reponame: project.try(:identifer),
|
||||
username: current_user.try(:login)
|
||||
}
|
||||
}
|
||||
|
||||
response = Gitea::Chain::ChainGetService.new(query_params).call
|
||||
return normal_status(-1, "获取token失败,请稍后重试") if response.status != 200
|
||||
return normal_status(-1, "您的token值不足") if response.body["balance"].to_i < params[:token].to_i
|
||||
else
|
||||
issue_params = issue_send_params(params)
|
||||
|
||||
|
@ -146,19 +134,6 @@ class IssuesController < ApplicationController
|
|||
tiding_type: 'issue', status: 0)
|
||||
end
|
||||
|
||||
#为悬赏任务时, 扣除当前用户的积分
|
||||
if params[:issue_type].to_s == "2"
|
||||
change_params = {
|
||||
type: "minus",
|
||||
chain_params: {
|
||||
amount: params[:token],
|
||||
reponame: @project.try(:identifer),
|
||||
username: current_user.try(:login)
|
||||
}
|
||||
}
|
||||
PostChainJob.perform_later(change_params)
|
||||
end
|
||||
|
||||
@issue.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "create")
|
||||
normal_status(0, "创建成功")
|
||||
else
|
||||
|
@ -220,24 +195,6 @@ class IssuesController < ApplicationController
|
|||
@issue.issue_times.update_all(end_time: Time.now)
|
||||
@issue.update_closed_issues_count_in_project!
|
||||
end
|
||||
|
||||
if @issue.issue_type.to_s == "2"
|
||||
#表示修改token值
|
||||
if @issue.saved_change_to_attribute("token")
|
||||
last_token = @issue.token_was
|
||||
change_token = last_token - @issue.token
|
||||
change_type = change_token > 0 ? "add" : "minus"
|
||||
change_params = {
|
||||
type: change_type,
|
||||
chain_params: {
|
||||
amount: change_token.abs,
|
||||
reponame: @project.try(:identifer),
|
||||
username: current_user.try(:login)
|
||||
}
|
||||
}
|
||||
PostChainJob.perform_later(change_params)
|
||||
end
|
||||
end
|
||||
@issue.create_journal_detail(change_files, issue_files, issue_file_ids, current_user&.id)
|
||||
normal_status(0, "更新成功")
|
||||
else
|
||||
|
@ -264,7 +221,6 @@ class IssuesController < ApplicationController
|
|||
|
||||
def destroy
|
||||
if @issue.destroy
|
||||
|
||||
normal_status(0, "删除成功")
|
||||
else
|
||||
normal_status(-1, "删除失败")
|
||||
|
|
|
@ -168,11 +168,8 @@ class RepositoriesController < ApplicationController
|
|||
}
|
||||
elsif hook_type == "pull_request" && params["action"].to_s == "closed" #合并请求合并后才会有上链操作
|
||||
uploadPushInfo = {
|
||||
"source_branch": params["head"]["ref"].to_s.split("/").last,
|
||||
"target_branch": params["base"]["ref"].to_s.split("/").last,
|
||||
"source_project_id": params["head"]["repo_id"].to_i, #现在是为gitea上仓库的id
|
||||
"target_project_id": params["base"]["repo_id"].to_i,
|
||||
"sha": [params["pull_request"]["merge_commit_sha"], params["pull_request"]["merge_base"]],
|
||||
"branch": params["base"]["ref"].to_s.split("/").last,
|
||||
"sha": params["pull_request"]["merge_base"],
|
||||
"modification_lines": 1 #pull_request中没有commits数量
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue