From e0588b7863938ec24d557f848f90dc29d7da7717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Fri, 11 Nov 2022 15:57:15 +0800 Subject: [PATCH 01/20] =?UTF-8?q?fixed=20=E5=A2=9E=E5=8A=A0=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E5=8F=91=E9=80=81=E8=80=85=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/mailers/user_mailer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 13cf2ac54..0b9c3aabc 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -1,7 +1,8 @@ class UserMailer < ApplicationMailer # 注意:这个地方一定要和你的邮箱服务域名一致 # default from: 'notification@trustie.org' - default from: 'noreply@gitlink.org.cn' + # default from: 'noreply@gitlink.org.cn' + default from: 'GitLink ' # 用户注册验证码 def register_email(mail, code) From 518f373b88935aabaf6be00170b37855b754cbf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Tue, 15 Nov 2022 10:03:01 +0800 Subject: [PATCH 02/20] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ucloud=E7=9F=AD?= =?UTF-8?q?=E4=BF=A1=E5=8F=91=E9=80=81=E9=80=9A=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 27 ++++++- app/services/sms/ucloud_service.rb | 98 +++++++++++++++++++++++ 2 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 app/services/sms/ucloud_service.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index eaffdeca0..97f975016 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -103,8 +103,10 @@ class ApplicationController < ActionController::Base when 1, 2, 4, 9 # 手机类型的发送 sigle_para = {phone: value} - status = Gitlink::Sms.send(mobile: value, code: code) - tip_exception(-2, code_msg(status)) if status != 0 + # status = Gitlink::Sms.send(mobile: value, code: code) + # tip_exception(-2, code_msg(status)) if status != 0 + status = Sms::UcloudService.call(value, code) + tip_exception(-2, ucloud_code_msg(status)) if status != 0 when 8, 3, 5 # 邮箱类型的发送 sigle_para = {email: value} @@ -149,6 +151,27 @@ class ApplicationController < ActionController::Base end end + def ucloud_code_msg status + case status + when 0 + "验证码已经发送到您的手机,请注意查收" + when 171 + "API签名错误" + when 18014 + "无效手机号码" + when 18017 + "无效模板" + when 18018 + "短信模板参数与短信模板不匹配" + when 18023 + "短信内容中含有运营商拦截的关键词" + when 18033 + "变量内容不符合规范" + else + "错误码#{status}" + end + end + def validate_type(object_type) normal_status(2, "参数") if params.has_key?(:sort_type) && !SORT_TYPE.include?(params[:sort_type].strip) end diff --git a/app/services/sms/ucloud_service.rb b/app/services/sms/ucloud_service.rb new file mode 100644 index 000000000..4f1005c6b --- /dev/null +++ b/app/services/sms/ucloud_service.rb @@ -0,0 +1,98 @@ +class Sms::UcloudService < ApplicationService + attr_reader :phone, :code + + def initialize(phone, code) + @phone = phone + @code = code + end + + def call + public_key = EduSetting.get("ucloud_public_key") || "4Z7QYDY0SumplMtmNmd9PERgPPFiMpR1R" + private_key = EduSetting.get("ucloud_private_key") || "7wxMoGoaQ1DtcQjDxgJrOGOXnIiZq4amEWvmi7eBtm2d" + + project_id = "org-3ozbh2" + sign_params = { + "Action" => "SendUSMSMessage", + "ProjectId" => project_id, + "TemplateId" => "UTA221114S2MGTY", + "PublicKey" => public_key, + "PhoneNumbers.0" => @phone, + "TemplateParams.0" => "#{@code}", + "SigContent" => "GitLink确实开源" + } + sequence = sign_params.sort.map { |k, v| "#{k}#{v}" }.join('') + # Rails.logger.info("create_signature=========#{sequence}#{private_key}") + req_params = sign_params.merge("Signature" => Digest::SHA1.hexdigest("#{sequence}#{private_key}")) + uri = URI("https://api.ucloud.cn") + uri.query = req_params.map { |k, v| "#{k}=#{URI.escape(v.to_s)}" }.join('&') + # Rails.logger.info("uri.query=========#{uri.query}") + + Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| + req = Net::HTTP::Get.new uri.request_uri + + response = http.request(req) + # Rails.logger.info("ucloud sms response.body=========#{response.body}") + result = ActiveSupport::JSON.decode(response.body) + result['RetCode'] + end + end + + def send_by_params(opt={}) + public_key = "4Z7QYDY0SumplMtmNmd9PERgPPFiMpRR" + private_key = "7wxMoGoaQ1DtcQjDxgJrOGOXnIiZq4amEWvmi7eBtmd" + + project_id = "org-3ozbh2" + sign_params = { + "Action" => "SendUSMSMessage", + "ProjectId" => project_id, + "TemplateId" => "#{opt[:TemplateId]}", + "PublicKey" => public_key, + "PhoneNumbers.0" => "#{opt[:PhoneNumbers]}", + "TemplateParams.0" => "#{opt[:TemplateParams]}", + "SigContent" => "GitLink确实开源" + } + sequence = sign_params.sort.map { |k, v| "#{k}#{v}" }.join('') + # Rails.logger.info("create_signature=========#{sequence}#{private_key}") + req_params = sign_params.merge("Signature" => Digest::SHA1.hexdigest("#{sequence}#{private_key}")) + uri = URI("https://api.ucloud.cn") + uri.query = req_params.map { |k, v| "#{k}=#{URI.escape(v.to_s)}" }.join('&') + # Rails.logger.info("uri.query=========#{uri.query}") + + Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| + req = Net::HTTP::Get.new uri.request_uri + + response = http.request(req) + # Rails.logger.info("ucloud sms response.body=========#{response.body}") + ActiveSupport::JSON.decode(response.body) + end + end + + def send_sms(template_id) + + end + + def GetProjectList + public_key = "4Z7QYDY0SumplMtmNmd9PERgPPFiMpRR" + private_key = "7wxMoGoaQ1DtcQjDxgJrOGOXnIiZq4amEWvmi7eBtmd" + + sign_params = { + "Action" => "GetProjectList", + "PublicKey" => public_key + } + sequence = sign_params.sort.map { |k, v| "#{k}#{v}" }.join('') + Rails.logger.info("create_signature=========#{sequence}#{private_key}") + req_params = sign_params.merge("Signature" => Digest::SHA1.hexdigest("#{sequence}#{private_key}")) + uri = URI("https://api.ucloud.cn") + uri.query = req_params.map { |k, v| "#{k}=#{URI.escape(v.to_s)}" }.join('&') + Rails.logger.info("uri.query=========#{uri.query}") + + Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| + req = Net::HTTP::Get.new uri.request_uri + + response = http.request(req) + Rails.logger.info("ucloud sms response.body=========#{response.body}") + response.body + end + end + +end From d4762d290020dd27a23ec525b36c15f5bdd6e2ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Tue, 15 Nov 2022 10:25:17 +0800 Subject: [PATCH 03/20] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/queries/projects/list_query.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/queries/projects/list_query.rb b/app/queries/projects/list_query.rb index 1e3e0db9b..66f0a43a8 100644 --- a/app/queries/projects/list_query.rb +++ b/app/queries/projects/list_query.rb @@ -37,7 +37,7 @@ class Projects::ListQuery < ApplicationQuery ids = Projects::ElasticsearchService.call(params[:search]) items = items.where(platform: 'forge') if ids.present? - items.where(id: ids).by_name_or_identifier(params[:search]) + items.where(id: ids).by_name_or_identifier(params[:search]).or.where(user_id: User.like(params[:search]).pluck(:id)) else items.by_name_or_identifier(params[:search]) end From 005687442e460a9ceb9045b3232b8ac13dacc11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Tue, 15 Nov 2022 10:27:19 +0800 Subject: [PATCH 04/20] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/queries/projects/list_query.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/queries/projects/list_query.rb b/app/queries/projects/list_query.rb index 66f0a43a8..76f235796 100644 --- a/app/queries/projects/list_query.rb +++ b/app/queries/projects/list_query.rb @@ -37,7 +37,7 @@ class Projects::ListQuery < ApplicationQuery ids = Projects::ElasticsearchService.call(params[:search]) items = items.where(platform: 'forge') if ids.present? - items.where(id: ids).by_name_or_identifier(params[:search]).or.where(user_id: User.like(params[:search]).pluck(:id)) + items.where(id: ids).by_name_or_identifier(params[:search]).or(Project.visible.where(user_id: User.like(params[:search]).pluck(:id))) else items.by_name_or_identifier(params[:search]) end From 64fdfd3b017c0090cfeb7020e9343fcb754d3b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Tue, 15 Nov 2022 10:33:41 +0800 Subject: [PATCH 05/20] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/queries/projects/list_query.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/queries/projects/list_query.rb b/app/queries/projects/list_query.rb index 76f235796..b613d1f01 100644 --- a/app/queries/projects/list_query.rb +++ b/app/queries/projects/list_query.rb @@ -37,10 +37,11 @@ class Projects::ListQuery < ApplicationQuery ids = Projects::ElasticsearchService.call(params[:search]) items = items.where(platform: 'forge') if ids.present? - items.where(id: ids).by_name_or_identifier(params[:search]).or(Project.visible.where(user_id: User.like(params[:search]).pluck(:id))) + items = items.where(id: ids).by_name_or_identifier(params[:search]) else - items.by_name_or_identifier(params[:search]) + items = items.by_name_or_identifier(params[:search]) end + items.or(Project.visible.where(user_id: User.like(params[:search]).pluck(:id))) end def by_project_type(items) From b05e08a1c521aa8c6f03a5566ed1b937c1b4abd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Tue, 15 Nov 2022 10:47:14 +0800 Subject: [PATCH 06/20] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/accounts_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index a418c5f37..28313f169 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -141,6 +141,7 @@ class AccountsController < ApplicationController Register::Form.new(register_params).validate! user = Users::RegisterService.call(register_params) + user.mail = "#{user.login}@example.org" if user.mail.blank? password = register_params[:password].strip # gitea用户注册, email, username, password From 62a9941e22e135c69b528a52c8507ec446e5fbca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Tue, 15 Nov 2022 14:00:31 +0800 Subject: [PATCH 07/20] =?UTF-8?q?fixed=20=E9=A1=B9=E7=9B=AE=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=9F=A5=E8=AF=A2=E6=8E=92=E5=BA=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/queries/projects/list_query.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/queries/projects/list_query.rb b/app/queries/projects/list_query.rb index b613d1f01..ce97fcd9c 100644 --- a/app/queries/projects/list_query.rb +++ b/app/queries/projects/list_query.rb @@ -17,7 +17,7 @@ class Projects::ListQuery < ApplicationQuery sort = params[:sort_by] || "updated_on" sort_direction = params[:sort_direction] || "desc" - # collection = optimize_sorting(collection, sort) if params[:category_id].present? + collection = optimize_sorting(collection, sort) if params[:category_id].present? custom_sort(collection, sort, sort_direction) # scope = scope.reorder("projects.#{sort} #{sort_direction}") From 64c6f69f56fb1fe5dc555eea2328e9090541261f Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 15 Nov 2022 14:25:35 +0800 Subject: [PATCH 08/20] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E9=A1=B9=E7=9B=AE=E5=88=86=E7=B1=BB=E4=B8=8B=E7=A7=81?= =?UTF-8?q?=E6=9C=89=E9=A1=B9=E7=9B=AE=E7=9A=84=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 11 +++++++++++ app/models/project_category.rb | 17 +++++++++-------- app/services/projects/create_service.rb | 9 +++++++++ .../admins/project_categories/_list.html.erb | 4 +++- ...rivate_projects_count_to_project_category.rb | 5 +++++ 5 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20221115032403_add_private_projects_count_to_project_category.rb diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 71e409dde..03944f1fb 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -154,6 +154,15 @@ class ProjectsController < ApplicationController } gitea_repo = Gitea::Repository::UpdateService.call(@owner, @project&.repository&.identifier, gitea_params) @project.repository.update_attributes({hidden: gitea_repo["private"], identifier: gitea_repo["name"]}) + # 更新对应所属分类下的项目数量(私有) + before_is_public = @project.previous_changes[:is_public].present? ? @project.previous_changes[:is_public][0] : @project.is_public + after_is_public = @project.previous_changes[:is_public].present? ? @project.previous_changes[:is_public][1] : @project.is_public + before_pc_id = @project.previous_changes[:project_category_id].present? ? @project.previous_changes[:project_category_id][0] : @project.project_category_id + after_pc_id = @project.previous_changes[:project_category_id].present? ? @project.previous_changes[:project_category_id][1] : @project.project_category_id + before_pc = ProjectCategory.find_by_id(before_pc_id) + after_pc = ProjectCategory.find_by_id(after_pc_id) + before_pc.decrement!(:private_projects_count, 1) if before_pc.present? && !before_is_public + after_pc.increment!(:private_projects_count, 1) if after_pc.present? && !after_is_public end SendTemplateMessageJob.perform_later('ProjectSettingChanged', current_user.id, @project&.id, @project.previous_changes.slice(:name, :description, :project_category_id, :project_language_id, :is_public, :identifier)) if Site.has_notice_menu? end @@ -171,6 +180,8 @@ class ProjectsController < ApplicationController Gitea::Repository::DeleteService.new(@project.owner, @project.identifier).call @project.destroy! @project.forked_projects.update_all(forked_from_project_id: nil) + # 如果该项目有所属的项目分类以及为私有项目,需要更新对应数量 + @project.project_category.decrement!(:private_projects_count, 1) if @project.project_category.present? && !@project.is_public render_ok end else diff --git a/app/models/project_category.rb b/app/models/project_category.rb index 4bba5423e..97a304259 100644 --- a/app/models/project_category.rb +++ b/app/models/project_category.rb @@ -2,14 +2,15 @@ # # Table name: project_categories # -# id :integer not null, primary key -# name :string(255) -# position :integer -# projects_count :integer default("0") -# created_at :datetime not null -# updated_at :datetime not null -# ancestry :string(255) -# pinned_index :integer default("0") +# id :integer not null, primary key +# name :string(255) +# position :integer +# projects_count :integer default("0") +# created_at :datetime not null +# updated_at :datetime not null +# ancestry :string(255) +# pinned_index :integer default("0") +# private_projects_count :integer default("0") # # Indexes # diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index 025883805..2b4523bf5 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -16,6 +16,7 @@ class Projects::CreateService < ApplicationService Project.update_common_projects_count! ProjectUnit.init_types(@project.id) Repositories::CreateService.new(user, @project, repository_params).call + upgrade_project_category_private_projects_count else Rails.logger.info("#############___________create_project_erros______###########{@project.errors.messages}") end @@ -28,6 +29,14 @@ class Projects::CreateService < ApplicationService private + def upgrade_project_category_private_projects_count + # 如果为空或者项目为公有项目直接返回 + return unless params[:project_category_id].present? + return if repo_is_public + project_category = ProjectCategory.find_by_id(params[:project_category_id]) + project_category.increment!(:private_projects_count, 1) + end + def authroize_user_id_success (user.id == params[:user_id].to_i) || (user.organizations.find_by_id(params[:user_id]).present?) end diff --git a/app/views/admins/project_categories/_list.html.erb b/app/views/admins/project_categories/_list.html.erb index 1a1626bc4..c4b70f52d 100644 --- a/app/views/admins/project_categories/_list.html.erb +++ b/app/views/admins/project_categories/_list.html.erb @@ -4,7 +4,8 @@ 序号 名称 <%= sort_tag('精选', name: 'pinned_index', path: admins_project_categories_path) %> - <%= sort_tag('项目数', name: 'projects_count', path: admins_project_categories_path) %> + <%= sort_tag('项目数', name: 'projects_count', path: admins_project_categories_path) %> + <%= sort_tag('私有项目数', name: 'private_projects_count', path: admins_project_categories_path) %> 精选项目数 <%= sort_tag('创建时间', name: 'created_at', path: admins_project_categories_path) %> 操作 @@ -20,6 +21,7 @@ <%= project_category.pinned_index == 0 ? "" : "√" %> <%= project_category.projects_count %> + <%= project_category.private_projects_count %> <%= project_category.projects.select(:id).where(is_pinned: true).size %> <%= project_category.created_at&.strftime('%Y-%m-%d %H:%M') %> diff --git a/db/migrate/20221115032403_add_private_projects_count_to_project_category.rb b/db/migrate/20221115032403_add_private_projects_count_to_project_category.rb new file mode 100644 index 000000000..8d2d92ffd --- /dev/null +++ b/db/migrate/20221115032403_add_private_projects_count_to_project_category.rb @@ -0,0 +1,5 @@ +class AddPrivateProjectsCountToProjectCategory < ActiveRecord::Migration[5.2] + def change + add_column :project_categories, :private_projects_count, :integer, default: 0 + end +end From 134a395ffa5d13fd2a4197d95e8f3d938b6defbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Tue, 15 Nov 2022 14:31:18 +0800 Subject: [PATCH 09/20] =?UTF-8?q?fixed=20=E5=8C=BA=E5=88=86=E6=89=BE?= =?UTF-8?q?=E5=9B=9E=E5=AF=86=E7=A0=81=E9=82=AE=E4=BB=B6=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 9 +++++++-- app/mailers/user_mailer.rb | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 97f975016..3cbc08c3c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -118,8 +118,13 @@ class ApplicationController < ActionController::Base send_email_control = LimitForbidControl::SendEmailCode.new(value) tip_exception(-1, '邮件发送太频繁,请稍后再试') if send_email_control.forbid? begin - UserMailer.register_email(value, code).deliver_now - + if send_type == 3 + UserMailer.find_password(value, code).deliver_now + elsif send_type == 5 + UserMailer.bind_email(value, code).deliver_now + else + UserMailer.register_email(value, code).deliver_now + end Rails.cache.write(send_email_limit_cache_key, 1, expires_in: 1.minute) send_email_control.increment! # Mailer.run.email_register(code, value) diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 0b9c3aabc..28bbccf63 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -10,6 +10,18 @@ class UserMailer < ApplicationMailer mail(to: mail, subject: 'Gitink | 注册验证码') end + # 用户找回密码 + def find_password(mail, code) + @code = code + mail(to: mail, subject: 'Gitink | 找回密码验证码') + end + + # 用户绑定邮箱 + def bind_email(mail, code) + @code = code + mail(to: mail, subject: 'Gitink | 绑定邮箱验证码') + end + def update_email(mail, code) @code = code mail(to: mail, subject: 'Gitink | 更改邮箱验证码') From 0cb6f233f3066561915c3266c78992cf0635a32e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Tue, 15 Nov 2022 14:40:37 +0800 Subject: [PATCH 10/20] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=84=E7=BB=87=E5=92=8C=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/owner.rb | 5 +++++ app/queries/projects/list_query.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/owner.rb b/app/models/owner.rb index b65ee0544..2763dc80f 100644 --- a/app/models/owner.rb +++ b/app/models/owner.rb @@ -68,4 +68,9 @@ class Owner < ApplicationRecord has_many :repositories, foreign_key: :user_id, dependent: :destroy has_many :applied_transfer_projects, dependent: :destroy + scope :like, lambda { |keywords| + sql = "CONCAT(lastname, firstname) LIKE :search OR nickname LIKE :search OR login LIKE :search " + where(sql, :search => "%#{keywords.strip}%") unless keywords.blank? + } + end diff --git a/app/queries/projects/list_query.rb b/app/queries/projects/list_query.rb index ce97fcd9c..0a3cc3a4c 100644 --- a/app/queries/projects/list_query.rb +++ b/app/queries/projects/list_query.rb @@ -41,7 +41,7 @@ class Projects::ListQuery < ApplicationQuery else items = items.by_name_or_identifier(params[:search]) end - items.or(Project.visible.where(user_id: User.like(params[:search]).pluck(:id))) + items.or(Project.visible.where(user_id: Owner.like(params[:search]).pluck(:id))) end def by_project_type(items) From 255b6153273b9281bc9864e69bb5cf58becb1037 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 15 Nov 2022 14:41:08 +0800 Subject: [PATCH 11/20] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E9=A6=96=E9=A1=B5=E5=88=86=E7=B1=BB=E5=90=8E=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/project_categories_controller.rb | 2 +- app/views/project_categories/group_list.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/project_categories_controller.rb b/app/controllers/project_categories_controller.rb index 67a040fef..490e22021 100644 --- a/app/controllers/project_categories_controller.rb +++ b/app/controllers/project_categories_controller.rb @@ -10,7 +10,7 @@ class ProjectCategoriesController < ApplicationController end def group_list - @project_categories = ProjectCategory.where('projects_count > 0').order(projects_count: :desc) + @project_categories = ProjectCategory.select("id, name, projects_count, private_projects_count, (projects_count - private_projects_count) as public_projects_count").having('public_projects_count > 0').order(projects_count: :desc) # projects = Project.no_anomory_projects.visible # @category_group_list = projects.joins(:project_category).group("project_categories.id", "project_categories.name").size end diff --git a/app/views/project_categories/group_list.json.jbuilder b/app/views/project_categories/group_list.json.jbuilder index f13d6ecff..cc26276f5 100644 --- a/app/views/project_categories/group_list.json.jbuilder +++ b/app/views/project_categories/group_list.json.jbuilder @@ -1,5 +1,5 @@ json.array! @project_categories do |category| json.id category.id json.name category.name - json.projects_count category.projects_count + json.projects_count category.public_projects_count end From ea7cf1cd1f160c2ee021b400abed23ceee50b874 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 15 Nov 2022 15:17:06 +0800 Subject: [PATCH 12/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/project_categories_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/project_categories_controller.rb b/app/controllers/project_categories_controller.rb index 490e22021..f6b3cbc9d 100644 --- a/app/controllers/project_categories_controller.rb +++ b/app/controllers/project_categories_controller.rb @@ -10,7 +10,7 @@ class ProjectCategoriesController < ApplicationController end def group_list - @project_categories = ProjectCategory.select("id, name, projects_count, private_projects_count, (projects_count - private_projects_count) as public_projects_count").having('public_projects_count > 0').order(projects_count: :desc) + @project_categories = ProjectCategory.select("id, name, projects_count, private_projects_count, (projects_count - private_projects_count) as public_projects_count").having('public_projects_count > 0').order(public_projects_count: :desc) # projects = Project.no_anomory_projects.visible # @category_group_list = projects.joins(:project_category).group("project_categories.id", "project_categories.name").size end From a1731f91a917b87bcc3ab1b7298679ebb92b93f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Tue, 15 Nov 2022 17:12:10 +0800 Subject: [PATCH 13/20] =?UTF-8?q?fixed=20=E9=99=84=E4=BB=B6=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 1f5d5f459..4409f04a9 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -213,20 +213,17 @@ class AttachmentsController < ApplicationController def attachment_candown unless current_user.admin? || current_user.business? candown = true - unless params[:type] == 'history' - if @file.container && current_user.logged? - if @file.container.is_a?(Issue) - course = @file.container.project - candown = course.member?(current_user) || course.is_public - elsif @file.container.is_a?(Journal) - course = @file.container.issue.project - candown = course.member?(current_user) || course.is_public - else - course = nil - end - tip_exception(403, "您没有权限进入") if course.present? && !candown - tip_exception(403, "您没有权限进入") if @file.container.is_a?(ApplyUserAuthentication) + if @file.container + if @file.container.is_a?(Issue) + project = @file.container.project + candown = project.is_public || (current_user.logged? && project.member?(current_user)) + elsif @file.container.is_a?(Journal) + project = @file.container.issue.project + candown = project.is_public || (current_user.logged? && project.member?(current_user)) + else + project = nil end + tip_exception(403, "您没有权限进入") if project.present? && !candown end end end From 8ff5ee1eec1f727b0d892ce3247f62cbc236229c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Tue, 15 Nov 2022 17:12:10 +0800 Subject: [PATCH 14/20] =?UTF-8?q?fixed=20=E9=99=84=E4=BB=B6=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 1f5d5f459..4409f04a9 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -213,20 +213,17 @@ class AttachmentsController < ApplicationController def attachment_candown unless current_user.admin? || current_user.business? candown = true - unless params[:type] == 'history' - if @file.container && current_user.logged? - if @file.container.is_a?(Issue) - course = @file.container.project - candown = course.member?(current_user) || course.is_public - elsif @file.container.is_a?(Journal) - course = @file.container.issue.project - candown = course.member?(current_user) || course.is_public - else - course = nil - end - tip_exception(403, "您没有权限进入") if course.present? && !candown - tip_exception(403, "您没有权限进入") if @file.container.is_a?(ApplyUserAuthentication) + if @file.container + if @file.container.is_a?(Issue) + project = @file.container.project + candown = project.is_public || (current_user.logged? && project.member?(current_user)) + elsif @file.container.is_a?(Journal) + project = @file.container.issue.project + candown = project.is_public || (current_user.logged? && project.member?(current_user)) + else + project = nil end + tip_exception(403, "您没有权限进入") if project.present? && !candown end end end From e183f48c02c144e45d3645dbf10789ce39f0be5b Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 16 Nov 2022 15:27:49 +0800 Subject: [PATCH 15/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E8=AF=B7=E6=B1=82=E6=9F=A5=E8=AF=A2=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=A1=BB=E6=A0=B9=E6=8D=AE=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E7=B1=BB=E5=9E=8B=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/issues/list_query_service.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/services/issues/list_query_service.rb b/app/services/issues/list_query_service.rb index bed8c4837..f7c23ddfd 100644 --- a/app/services/issues/list_query_service.rb +++ b/app/services/issues/list_query_service.rb @@ -17,7 +17,11 @@ class Issues::ListQueryService < ApplicationService issues = all_issues.issue_index_includes issues = issues.includes(pull_request: :reviewers) if status_type.to_s == "2" #表示关闭中的 - issues = issues.where(status_id: 5) + if(select_type == "Issue") + issues = issues.where(status_id: 5) + else + issues = issues.joins(:pull_request).where(pull_requests: {status: 2}) + end elsif status_type.to_s == "1" if(select_type == "Issue") issues = issues.where.not(status_id: 5) #默认显示开启中的 From 6d3c7ddac44f490ff006b822ed714f185b181dbe Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 16 Nov 2022 15:27:49 +0800 Subject: [PATCH 16/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E8=AF=B7=E6=B1=82=E6=9F=A5=E8=AF=A2=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=A1=BB=E6=A0=B9=E6=8D=AE=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E7=B1=BB=E5=9E=8B=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/issues/list_query_service.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/services/issues/list_query_service.rb b/app/services/issues/list_query_service.rb index bed8c4837..f7c23ddfd 100644 --- a/app/services/issues/list_query_service.rb +++ b/app/services/issues/list_query_service.rb @@ -17,7 +17,11 @@ class Issues::ListQueryService < ApplicationService issues = all_issues.issue_index_includes issues = issues.includes(pull_request: :reviewers) if status_type.to_s == "2" #表示关闭中的 - issues = issues.where(status_id: 5) + if(select_type == "Issue") + issues = issues.where(status_id: 5) + else + issues = issues.joins(:pull_request).where(pull_requests: {status: 2}) + end elsif status_type.to_s == "1" if(select_type == "Issue") issues = issues.where.not(status_id: 5) #默认显示开启中的 From 4e6e654e1fe462548846887b817ff51ca10b8f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Wed, 27 Jul 2022 16:17:25 +0800 Subject: [PATCH 17/20] =?UTF-8?q?banner=E9=85=8D=E7=BD=AE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=B7=B3=E8=BD=ACURL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admins/topic/banners/_form_modal.html.erb | 6 ++++++ app/views/admins/topic/banners/_list.html.erb | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/views/admins/topic/banners/_form_modal.html.erb b/app/views/admins/topic/banners/_form_modal.html.erb index 20bca80c6..845b17027 100644 --- a/app/views/admins/topic/banners/_form_modal.html.erb +++ b/app/views/admins/topic/banners/_form_modal.html.erb @@ -15,6 +15,12 @@ <%= p.text_field :title,class: "form-control input-lg",required: true%> +
+ + <%= p.text_field :url, class: "form-control",placeholder: ""%> +