forked from Gitlink/forgeplus
Merge pull request '同步镜像项目增加重试机制,更新项目去掉一些验证,易修访问权限修复' (#160) from yystopf/forgeplus:hh_fix_bug into develop
This commit is contained in:
commit
4f3dc2b627
|
@ -160,6 +160,7 @@ class IssuesController < ApplicationController
|
|||
def update
|
||||
last_token = @issue.token
|
||||
last_status_id = @issue.status_id
|
||||
@issue&.issue_tags_relates&.destroy_all if params[:issue_tag_ids].blank?
|
||||
if params[:issue_tag_ids].present? && !@issue&.issue_tags_relates.where(issue_tag_id: params[:issue_tag_ids]).exists?
|
||||
@issue&.issue_tags_relates&.destroy_all
|
||||
params[:issue_tag_ids].each do |tag|
|
||||
|
@ -432,22 +433,22 @@ class IssuesController < ApplicationController
|
|||
|
||||
def check_project_public
|
||||
unless @project.is_public || @project.member?(current_user) || current_user.admin? || (@project.user_id == current_user.id)
|
||||
normal_status(-1, "您没有权限")
|
||||
return render_forbidden
|
||||
end
|
||||
end
|
||||
|
||||
def set_issue
|
||||
@issue = Issue.find_by_id(params[:id])
|
||||
if @issue.blank?
|
||||
normal_status(-1, "标签不存在")
|
||||
elsif @issue.is_lock &&!(@project.member?(current_user) || current_user.admin?)
|
||||
normal_status(-1, "您没有权限")
|
||||
return render_not_found
|
||||
elsif !(@project.is_public || (current_user.present? && (@project.member?(current_user) || current_user&.admin? || (@project.user_id == current_user&.id))))
|
||||
return render_forbidden
|
||||
end
|
||||
end
|
||||
|
||||
def check_issue_permission
|
||||
unless @project.is_public || (current_user.present? && (@project.member?(current_user) || current_user&.admin? || (@project.user_id == current_user&.id)))
|
||||
normal_status(-1, "您没有权限")
|
||||
return render_forbidden
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -79,12 +79,13 @@ class PullRequestsController < ApplicationController
|
|||
if params[:title].nil?
|
||||
normal_status(-1, "名称不能为空")
|
||||
elsif params[:issue_tag_ids].nil?
|
||||
normal_status(-1, "标签不能为空")
|
||||
normal_status(-1, "标记不能为空")
|
||||
else
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
merge_params
|
||||
|
||||
@issue&.issue_tags_relates&.destroy_all if params[:issue_tag_ids].blank?
|
||||
if params[:issue_tag_ids].present? && !@issue&.issue_tags_relates.where(issue_tag_id: params[:issue_tag_ids]).exists?
|
||||
@issue&.issue_tags_relates&.destroy_all
|
||||
params[:issue_tag_ids].each do |tag|
|
||||
|
|
|
@ -2,11 +2,15 @@ class BaseForm
|
|||
include ActiveModel::Model
|
||||
|
||||
def check_project_category(project_category_id)
|
||||
raise "project_category_id参数值无效." if project_category_id && !ProjectCategory.exists?(project_category_id)
|
||||
unless project_category_id == ''
|
||||
raise "project_category_id参数值无效." if project_category_id && !ProjectCategory.exists?(project_category_id)
|
||||
end
|
||||
end
|
||||
|
||||
def check_project_language(project_language_id)
|
||||
raise "project_language_id参数值无效." if project_language_id && !ProjectLanguage.exists?(project_language_id)
|
||||
unless project_language_id == ''
|
||||
raise "project_language_id参数值无效." if project_language_id && !ProjectLanguage.exists?(project_language_id)
|
||||
end
|
||||
end
|
||||
|
||||
def check_repository_name(user_id, repository_name)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Projects::UpdateForm < BaseForm
|
||||
attr_accessor :name, :description, :project_category_id, :project_language_id, :private
|
||||
validates :name, :description, :project_category_id, :project_language_id, presence: true
|
||||
validates :name, presence: true
|
||||
validates :name, length: { maximum: 50 }
|
||||
validates :description, length: { maximum: 200 }
|
||||
validate do
|
||||
|
|
|
@ -18,12 +18,30 @@ class BroadcastMirrorRepoMsgJob < ApplicationJob
|
|||
id: project.id,
|
||||
type: project.numerical_for_project_type
|
||||
}
|
||||
# 新增失败重试机制, 重试三次
|
||||
result = broadcast(project, json_data)
|
||||
|
||||
if result == 0
|
||||
count = 3
|
||||
while count > 0
|
||||
sleep 3.seconds
|
||||
result = broadcast(project, json_data)
|
||||
if result > 0
|
||||
break
|
||||
end
|
||||
count -= 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def broadcast(project, json_data)
|
||||
puts "############ broadcast start.......... "
|
||||
puts "############ broadcast channel_name: channel_room_#{project.id}"
|
||||
puts "############ broadcast project data: #{json_data} "
|
||||
|
||||
cable_result = ActionCable.server.broadcast "channel_room_#{project.id}", project: json_data
|
||||
|
||||
puts "############ broadcast result: #{cable_result == 1 ? 'successed' : 'failed'} "
|
||||
puts "############ broadcast result: #{cable_result > 0 ? 'successed' : 'failed'} "
|
||||
return cable_result
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,5 +16,6 @@ class MigrateRemoteRepositoryJob < ApplicationJob
|
|||
else
|
||||
repo&.mirror&.failed!
|
||||
end
|
||||
BroadcastMirrorRepoMsgJob.perform_later(repo.id) unless repo&.mirror.waiting?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,6 +26,7 @@ class SyncMirroredRepositoryJob < ApplicationJob
|
|||
result = Gitea::Repository::SyncMirroredService.call(repo.owner.login,
|
||||
repo.identifier, token: user.gitea_token)
|
||||
repo&.mirror.set_status! if result[:status] === 200
|
||||
BroadcastMirrorRepoMsgJob.perform_later(repo.id) unless repo&.mirror.waiting?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ class Mirror < ApplicationRecord
|
|||
# 0: 同步镜像成功;1: 正在同步镜像;2: 同步失败; 默认值为0
|
||||
enum status: { succeeded: 0, waiting: 1, failed: 2 }
|
||||
|
||||
after_update :websocket_boardcast, if: :saved_change_to_status?
|
||||
# after_update :websocket_boardcast, if: :saved_change_to_status?
|
||||
|
||||
belongs_to :repository, foreign_key: :repo_id
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ zh-CN:
|
|||
branch_name: 分支
|
||||
close_pr: 合并
|
||||
merge: 合并
|
||||
issue_tags_value: 标签
|
||||
issue_tags_value: 标记
|
||||
lock_issue: 锁定工单
|
||||
unlock_issue: 解锁工单
|
||||
destroy_issue_depend: 删除依赖
|
||||
|
@ -55,7 +55,7 @@ zh-CN:
|
|||
f: 否
|
||||
true: 是
|
||||
false: 否
|
||||
issue_tag_ids: 标签
|
||||
issue_tag_ids: 标记
|
||||
issue_type: 分类
|
||||
token: 悬赏金额
|
||||
close_issue: 工单
|
||||
|
|
Loading…
Reference in New Issue