From 3d12db3a077f234021820ed740588ff68b512dd5 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 14 Dec 2021 09:39:26 +0800 Subject: [PATCH 1/4] fix: atme service use perform later --- app/services/atme_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/atme_service.rb b/app/services/atme_service.rb index 623b32c09..29c4b127e 100644 --- a/app/services/atme_service.rb +++ b/app/services/atme_service.rb @@ -32,6 +32,6 @@ class AtmeService < ApplicationService else return end - SendTemplateMessageJob.perform_now(message_source, receivers, user.id, @atmeable.id) if Site.has_notice_menu? + SendTemplateMessageJob.perform_later(message_source, receivers, user.id, @atmeable.id) if Site.has_notice_menu? end end From 6a2ad67386e8bc0b0e12aea687f0810039edf482 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 14 Dec 2021 09:53:54 +0800 Subject: [PATCH 2/4] fix --- app/jobs/send_template_message_job.rb | 2 ++ app/services/atme_service.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/jobs/send_template_message_job.rb b/app/jobs/send_template_message_job.rb index 125ed3e0b..900e8b84d 100644 --- a/app/jobs/send_template_message_job.rb +++ b/app/jobs/send_template_message_job.rb @@ -37,6 +37,7 @@ class SendTemplateMessageJob < ApplicationJob issue = Issue.find_by_id(issue_id) return unless operator.present? && issue.present? # receivers = receivers.where.not(id: operator&.id) + receivers = User.where(id: receivers) receivers_string, content, notification_url = MessageTemplate::IssueAtme.get_message_content(receivers, operator, issue) Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, issue_id: issue.id}, 2, operator_id) when 'IssueChanged' @@ -235,6 +236,7 @@ class SendTemplateMessageJob < ApplicationJob pull_request = PullRequest.find_by_id(pull_request_id) return unless operator.present? && pull_request.present? # receivers = receivers.where.not(id: operator&.id) + receivers = User.where(id: receivers) receivers_string, content, notification_url = MessageTemplate::PullRequestAtme.get_message_content(receivers, operator, pull_request) Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, pull_request_id: pull_request.id}, 2, operator_id) when 'PullRequestChanged' diff --git a/app/services/atme_service.rb b/app/services/atme_service.rb index 29c4b127e..f93314e47 100644 --- a/app/services/atme_service.rb +++ b/app/services/atme_service.rb @@ -32,6 +32,6 @@ class AtmeService < ApplicationService else return end - SendTemplateMessageJob.perform_later(message_source, receivers, user.id, @atmeable.id) if Site.has_notice_menu? + SendTemplateMessageJob.perform_later(message_source, receivers.pluck(:id), user.id, @atmeable.id) if Site.has_notice_menu? end end From e3df503dd2814b9e482c1eb758e72f33d7ce9cbd Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 14 Dec 2021 10:13:28 +0800 Subject: [PATCH 3/4] fix --- app/services/notice/write/client_service.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/services/notice/write/client_service.rb b/app/services/notice/write/client_service.rb index c76691cfb..d9dc841f6 100644 --- a/app/services/notice/write/client_service.rb +++ b/app/services/notice/write/client_service.rb @@ -59,6 +59,8 @@ class Notice::Write::ClientService < ApplicationService req.request :url_encoded req.headers['Content-Type'] = 'application/json' req.adapter Faraday.default_adapter + req.options.timeout = 100 # open/read timeout in seconds + req.options.open_timeout = 10 # connection open timeout in seconds end end From efc82b984127c04f5788a08490acada00da7ab36 Mon Sep 17 00:00:00 2001 From: xiaoxiaoqiong Date: Wed, 24 Nov 2021 18:13:15 +0800 Subject: [PATCH 4/4] fix: issue is collaborators --- app/forms/base_form.rb | 20 +++++++++++++++++++ app/models/issue.rb | 4 ++++ app/views/issues/edit.json.jbuilder | 1 + .../forms/projects_create_form.zh-CN.yml | 12 +++++------ 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/app/forms/base_form.rb b/app/forms/base_form.rb index 437217f00..be1c1e1a1 100644 --- a/app/forms/base_form.rb +++ b/app/forms/base_form.rb @@ -26,6 +26,26 @@ class BaseForm raise "项目标识已被占用." if ReversedKeyword.check_exists?(repository_name) end + def check_password(password) + password = strip(password) + raise PasswordFormatError, "密码8~16位密码,支持字母数字和符号" unless password =~ CustomRegexp::PASSWORD + end + + def check_password_confirmation(password, password_confirmation) + password = strip(password) + password_confirmation = strip(password_confirmation) + + raise PasswordFormatError, "确认密码为8~16位密码,支持字母数字和符号" unless password_confirmation =~ CustomRegexp::PASSWORD + raise PasswordConfirmationError, "两次输入的密码不一致" unless password == password_confirmation + end + + def check_verifi_code(verifi_code, code) + code = strip(code) + # return if code == "123123" # TODO 万能验证码,用于测试 + raise VerifiCodeError, "验证码已失效" if !verifi_code&.effective? + raise VerifiCodeError, "验证码不正确" if verifi_code&.code != code + end + private def strip(str) str.to_s.strip.presence diff --git a/app/models/issue.rb b/app/models/issue.rb index 9c195d121..cecc4678c 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -153,6 +153,10 @@ class Issue < ApplicationRecord end end + def is_collaborators? + self.assigned_to_id.present? ? self.project.member?(self.assigned_to_id) : false + end + def get_issue_tags_name if issue_tags.present? issue_tags.select(:name).uniq.pluck(:name).join(",") diff --git a/app/views/issues/edit.json.jbuilder b/app/views/issues/edit.json.jbuilder index eae63c3c7..5b8ff23ba 100644 --- a/app/views/issues/edit.json.jbuilder +++ b/app/views/issues/edit.json.jbuilder @@ -5,6 +5,7 @@ json.done_ratio @issue.done_ratio.to_s + "%" json.issue_tags @issue.get_issue_tags json.cannot_edit_tags @cannot_edit_tags json.issue_current_user @issue.author_id == current_user.try(:id) +json.assigned_to_id @issue.is_collaborators? ? @issue.assigned_to_id : nil # json.issue_chosen @issue_chosen # json.branches @all_branches json.attachments do diff --git a/config/locales/forms/projects_create_form.zh-CN.yml b/config/locales/forms/projects_create_form.zh-CN.yml index e36a0520a..54de8e71a 100644 --- a/config/locales/forms/projects_create_form.zh-CN.yml +++ b/config/locales/forms/projects_create_form.zh-CN.yml @@ -1,7 +1,7 @@ -'zh-CN': - activemodel: - attributes: - projects/create_form: - name: 项目名称 - repository_name: 仓库名称 +'zh-CN': + activemodel: + attributes: + projects/create_form: + name: 项目名称 + repository_name: 项目标识 description: 项目简介 \ No newline at end of file