From 4aac05d4e1c1130e21e6024be3ccd9ce413b1c8d Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 16 Feb 2022 11:17:03 +0800 Subject: [PATCH 01/12] fix: build user template message data must fronted --- app/controllers/users/template_message_settings_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users/template_message_settings_controller.rb b/app/controllers/users/template_message_settings_controller.rb index 5421a29d5..d38e6614d 100644 --- a/app/controllers/users/template_message_settings_controller.rb +++ b/app/controllers/users/template_message_settings_controller.rb @@ -22,9 +22,9 @@ class Users::TemplateMessageSettingsController < Users::BaseController def get_current_setting @current_setting = @_observed_user.user_template_message_setting + @current_setting = UserTemplateMessageSetting.build(@_observed_user.id) if @current_setting.nil? @current_setting.notification_body.merge!(UserTemplateMessageSetting.init_notification_body.except(*@current_setting.notification_body.keys)) @current_setting.email_body.merge!(UserTemplateMessageSetting.init_email_body.except(*@current_setting.email_body.keys)) - @current_setting = UserTemplateMessageSetting.build(@_observed_user.id) if @current_setting.nil? end def setting_params From 1ac2ddfaa5805047a57ced72452f816dc0b4b284 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 16 Feb 2022 11:46:34 +0800 Subject: [PATCH 02/12] fix: default setting for new template message --- app/jobs/send_template_message_job.rb | 4 +++ app/models/message_template/issue_expire.rb | 28 ++++++++++++------- app/models/message_template/project_forked.rb | 4 ++- .../message_template/project_milestone.rb | 6 +++- .../project_milestone_completed.rb | 8 ++++-- .../message_template/project_praised.rb | 4 ++- 6 files changed, 39 insertions(+), 15 deletions(-) diff --git a/app/jobs/send_template_message_job.rb b/app/jobs/send_template_message_job.rb index 4cde94c4b..de75024dd 100644 --- a/app/jobs/send_template_message_job.rb +++ b/app/jobs/send_template_message_job.rb @@ -52,6 +52,10 @@ class SendTemplateMessageJob < ApplicationJob receivers = User.where(id: [issue&.assigned_to_id, issue&.author_id]) receivers_string, content, notification_url = MessageTemplate::IssueExpire.get_message_content(receivers, issue) Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {issue_id: issue.id}) + receivers.find_each do |receiver| + receivers_email_string, email_title, email_content = MessageTemplate::IssueExpire.get_email_message_content(receiver, issue) + Notice::Write::EmailCreateService.call(receivers_email_string, email_title, email_content) + end when 'IssueDeleted' operator_id, issue_title, issue_assigned_to_id, issue_author_id = args[0], args[1], args[2], args[3] operator = User.find_by_id(operator_id) diff --git a/app/models/message_template/issue_expire.rb b/app/models/message_template/issue_expire.rb index 88593d848..aae3a3c9b 100644 --- a/app/models/message_template/issue_expire.rb +++ b/app/models/message_template/issue_expire.rb @@ -16,15 +16,21 @@ class MessageTemplate::IssueExpire < MessageTemplate # MessageTemplate::IssueCreatorExpire.get_message_content(User.where(login: 'yystopf'), Issue.last) - def self.get_message_content(receiver, issue) - if receiver.user_template_message_setting.present? - return '', '', '' unless receiver.user_template_message_setting.email_body["Normal::IssueExpire"] - project = issue&.project - owner = project&.owner - content = sys_notice.gsub('{title}', issue&.subject) - url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier).gsub('{id}', issue&.id.to_s) - - return receivers_string(receivers), content, url + def self.get_message_content(receivers, issue) + receivers.each do |receiver| + if receiver.user_template_message_setting.present? + send_setting = receiver.user_template_message_setting.notification_body["CreateOrAssign::IssueExpire"] + send_setting = send_setting.nil? ? UserTemplateMessageSetting.init_notification_body["CreateOrAssign::IssueExpire"] : send_setting + receivers = receivers.where.not(id: receiver.id) unless send_setting + end + end + return '', '', '' if receivers.blank? + project = issue&.project + owner = project&.owner + content = sys_notice.gsub('{title}', issue&.subject) + url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier).gsub('{id}', issue&.id.to_s) + + return receivers_string(receivers), content, url else return '', '', '' end @@ -35,7 +41,9 @@ class MessageTemplate::IssueExpire < MessageTemplate def self.get_email_message_content(receiver, issue) if receiver.user_template_message_setting.present? - return '', '', '' unless receiver.user_template_message_setting.email_body["Normal::IssueExpire"] + send_setting = receiver.user_template_message_setting.init_email_body["CreateOrAssign::IssueExpire"] + send_setting = send_setting.nil? ? UserTemplateMessageSetting.init_email_body["CreateOrAssign::IssueExpire"] : send_setting + return '', '', '' unless send_setting project = issue&.project owner = project&.owner diff --git a/app/models/message_template/project_forked.rb b/app/models/message_template/project_forked.rb index a395d0db6..c119feed6 100644 --- a/app/models/message_template/project_forked.rb +++ b/app/models/message_template/project_forked.rb @@ -19,7 +19,9 @@ class MessageTemplate::ProjectForked < MessageTemplate def self.get_message_content(receivers, user, project) receivers.each do |receiver| if receiver.user_template_message_setting.present? - receivers = receivers.where.not(id: receiver.id) unless receiver.user_template_message_setting.notification_body["ManageProject::Forked"] + send_setting = receiver.user_template_message_setting.notification_body["ManageProject::Forked"] + send_setting = send_setting.nil? ? UserTemplateMessageSetting.init_notification_body["ManageProject::Forked"] : send_setting + receivers = receivers.where.not(id: receiver.id) unless send_setting end end return '', '', '' if receivers.blank? diff --git a/app/models/message_template/project_milestone.rb b/app/models/message_template/project_milestone.rb index 8c9c47d16..3436908e0 100644 --- a/app/models/message_template/project_milestone.rb +++ b/app/models/message_template/project_milestone.rb @@ -19,6 +19,8 @@ class MessageTemplate::ProjectMilestone < MessageTemplate def self.get_message_content(receivers, operator, milestone) receivers.each do |receiver| if receiver.user_template_message_setting.present? + send_setting = receiver.user_template_message_setting.notification_body["ManageProject::Milestone"] + send_setting = send_setting.nil? ? UserTemplateMessageSetting.init_notification_body["ManageProject::Milestone"] : send_setting receivers = receivers.where.not(id: receiver.id) unless receiver.user_template_message_setting.notification_body["ManageProject::Milestone"] end end @@ -36,7 +38,9 @@ class MessageTemplate::ProjectMilestone < MessageTemplate def self.get_email_message_content(receiver, operator, milestone) if receiver.user_template_message_setting.present? - return '', '', '' unless receiver.user_template_message_setting.email_body["ManageProject::Milestone"] + send_setting = receiver.user_template_message_setting.email_body["ManageProject::Milestone"] + send_setting = send_setting.nil? ? UserTemplateMessageSetting.init_email_body["ManageProject::Milestone"] : send_setting + return '', '', '' unless send_setting project = milestone&.project owner = project&.owner title = email_title diff --git a/app/models/message_template/project_milestone_completed.rb b/app/models/message_template/project_milestone_completed.rb index eec895a6b..899af8d61 100644 --- a/app/models/message_template/project_milestone_completed.rb +++ b/app/models/message_template/project_milestone_completed.rb @@ -19,7 +19,9 @@ class MessageTemplate::ProjectMilestoneCompleted < MessageTemplate def self.get_message_content(receivers, milestone) receivers.each do |receiver| if receiver.user_template_message_setting.present? - receivers = receivers.where.not(id: receiver.id) unless receiver.user_template_message_setting.notification_body["ManageProject::MilestoneCompleted"] + send_setting = receiver.user_template_message_setting.notification_body["ManageProject::MilestoneCompleted"] + send_setting = send_setting.nil? ? UserTemplateMessageSetting.init_notification_body["ManageProject::MilestoneCompleted"] : send_setting + receivers = receivers.where.not(id: receiver.id) unless send_setting end end return '', '', '' if receivers.blank? @@ -36,7 +38,9 @@ class MessageTemplate::ProjectMilestoneCompleted < MessageTemplate def self.get_email_message_content(receiver, milestone) if receiver.user_template_message_setting.present? - return '', '', '' unless receiver.user_template_message_setting.email_body["ManageProject::MilestoneCompleted"] + send_setting = receiver.user_template_message_setting.email_body["ManageProject::MilestoneCompleted"] + send_setting = send_setting.nil? ? UserTemplateMessageSetting.init_email_body["ManageProject::MilestoneCompleted"] : send_setting + return '', '', '' unless send_setting project = milestone&.project owner = project&.owner title = email_title diff --git a/app/models/message_template/project_praised.rb b/app/models/message_template/project_praised.rb index 35af6148f..1686b3197 100644 --- a/app/models/message_template/project_praised.rb +++ b/app/models/message_template/project_praised.rb @@ -19,7 +19,9 @@ class MessageTemplate::ProjectPraised < MessageTemplate def self.get_message_content(receivers, user, project) receivers.each do |receiver| if receiver.user_template_message_setting.present? - receivers = receivers.where.not(id: receiver.id) unless receiver.user_template_message_setting.notification_body["ManageProject::Praised"] + send_setting = receiver.user_template_message_setting.notification_body["ManageProject::Praised"] + send_setting = send_setting.nil? ? UserTemplateMessageSetting.init_notification_body["ManageProject::Praised"] : send_setting + receivers = receivers.where.not(id: receiver.id) unless send_setting end end return '', '', '' if receivers.blank? From 5701c818ed30ccfa01be1b02e1edd5cd013c35a5 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 16 Feb 2022 15:10:10 +0800 Subject: [PATCH 03/12] fix --- app/models/message_template/issue_expire.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/models/message_template/issue_expire.rb b/app/models/message_template/issue_expire.rb index aae3a3c9b..206a09882 100644 --- a/app/models/message_template/issue_expire.rb +++ b/app/models/message_template/issue_expire.rb @@ -31,9 +31,6 @@ class MessageTemplate::IssueExpire < MessageTemplate url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier).gsub('{id}', issue&.id.to_s) return receivers_string(receivers), content, url - else - return '', '', '' - end rescue => e Rails.logger.info("MessageTemplate::IssueExpire.get_message_content [ERROR] #{e}") return '', '', '' From c956667ce0951e194359fcbbd2acd51a4860888e Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 17 Feb 2022 09:36:49 +0800 Subject: [PATCH 04/12] fix --- app/models/message_template/issue_expire.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/message_template/issue_expire.rb b/app/models/message_template/issue_expire.rb index 206a09882..09ae80880 100644 --- a/app/models/message_template/issue_expire.rb +++ b/app/models/message_template/issue_expire.rb @@ -38,7 +38,7 @@ class MessageTemplate::IssueExpire < MessageTemplate def self.get_email_message_content(receiver, issue) if receiver.user_template_message_setting.present? - send_setting = receiver.user_template_message_setting.init_email_body["CreateOrAssign::IssueExpire"] + send_setting = receiver.user_template_message_setting.email_body["CreateOrAssign::IssueExpire"] send_setting = send_setting.nil? ? UserTemplateMessageSetting.init_email_body["CreateOrAssign::IssueExpire"] : send_setting return '', '', '' unless send_setting project = issue&.project From a7a6abd22aaf9db7fa71176fefe558abde85d716 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 17 Feb 2022 09:40:44 +0800 Subject: [PATCH 05/12] fix: add rule for issue expire --- app/models/issue.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index c00f4e767..2a3b95958 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -75,7 +75,7 @@ class Issue < ApplicationRecord scope :issue_index_includes, ->{includes(:tracker, :priority, :version, :issue_status, :journals,:issue_tags,user: :user_extension)} scope :closed, ->{where(status_id: 5)} after_create :incre_project_common, :incre_user_statistic, :incre_platform_statistic - after_save :change_versions_count + after_save :change_versions_count, :send_update_message_to_notice_system after_destroy :update_closed_issues_count_in_project!, :decre_project_common, :decre_user_statistic, :decre_platform_statistic def incre_project_common @@ -199,4 +199,8 @@ class Issue < ApplicationRecord self.project.decrement!(:closed_issues_count) if self.status_id == 5 end + def send_update_message_to_notice_system + SendTemplateMessageJob.perform_later('IssueExpire', self.id) if Site.has_notice_menu? && self.due_date == Date.today + 1.days + end + end From d6633cb73a9db88b147444dc78d0b24fd2263ffb Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 17 Feb 2022 09:43:44 +0800 Subject: [PATCH 06/12] fix --- app/models/message_template/issue_expire.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/message_template/issue_expire.rb b/app/models/message_template/issue_expire.rb index 09ae80880..d77965f13 100644 --- a/app/models/message_template/issue_expire.rb +++ b/app/models/message_template/issue_expire.rb @@ -43,6 +43,7 @@ class MessageTemplate::IssueExpire < MessageTemplate return '', '', '' unless send_setting project = issue&.project owner = project&.owner + title = email_title content = email content.gsub!('{receiver}', receiver&.real_name) From 90dbe0730a44f0745c56b3ff46f1a16856ea3629 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 17 Feb 2022 10:59:18 +0800 Subject: [PATCH 07/12] fix: job not affect --- app/jobs/cache_async_clear_job.rb | 2 ++ app/models/project.rb | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/jobs/cache_async_clear_job.rb b/app/jobs/cache_async_clear_job.rb index 651dfaf41..1d810781a 100644 --- a/app/jobs/cache_async_clear_job.rb +++ b/app/jobs/cache_async_clear_job.rb @@ -7,6 +7,8 @@ class CacheAsyncClearJob < ApplicationJob Cache::V2::ProjectCommonService.new(id).clear when "owner_common_service" Cache::V2::OwnnerCommonService.new(id).clear + when "project_rank_service" + Cache::V2::ProjectRankService.new(id).clear end end end \ No newline at end of file diff --git a/app/models/project.rb b/app/models/project.rb index e671f0a6e..cfe9adb12 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -129,8 +129,8 @@ class Project < ApplicationRecord has_many :has_pinned_users, through: :pinned_projects, source: :user has_many :webhooks, class_name: "Gitea::Webhook", primary_key: :gpid, foreign_key: :repo_id after_create :incre_user_statistic, :incre_platform_statistic - after_save :check_project_members, :reset_cache_data - before_save :set_invite_code, :reset_unmember_followed, :set_recommend_and_is_pinned + after_save :check_project_members + before_save :set_invite_code, :reset_unmember_followed, :set_recommend_and_is_pinned, :reset_cache_data before_destroy :decre_project_common, :decre_forked_from_project_count after_destroy :decre_user_statistic, :decre_platform_statistic scope :project_statics_select, -> {select(:id,:name, :is_public, :identifier, :status, :project_type, :user_id, :forked_count, :description, :visits, :project_category_id, :project_language_id, :license_id, :ignore_id, :watchers_count, :created_on)} @@ -154,7 +154,7 @@ class Project < ApplicationRecord end def reset_cache_data - CacheAsyncResetJob.perform_later("project_common_service", self.id) + CacheAsyncResetJob.set(wait: 5.seconds).perform_later("project_common_service", self.id) if changes[:user_id].present? CacheAsyncSetJob.perform_later("user_statistic_service", {project_count: -1}, changes[:user_id].first) CacheAsyncSetJob.perform_later("user_statistic_service", {project_count: 1}, changes[:user_id].last) @@ -167,6 +167,11 @@ class Project < ApplicationRecord CacheAsyncSetJob.perform_later("platform_statistic_service", {project_language_count_key: first_language&.name, project_language_count: -1}) CacheAsyncSetJob.perform_later("platform_statistic_service", {project_language_count_key: last_language&.name, project_language_count: 1}) end + if changes[:is_public].present? + if changes[:is_public][0] && !changes[:is_public][1] + CacheAsyncClearJob.perform_later('project_rank_service', self.id) + end + end end def decre_project_common From b11f5fd22869f787ef9137dd36999d228bd19103 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 17 Feb 2022 11:12:50 +0800 Subject: [PATCH 08/12] fix: cache rollback --- app/models/project.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/project.rb b/app/models/project.rb index cfe9adb12..2e47c000f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -171,6 +171,9 @@ class Project < ApplicationRecord if changes[:is_public][0] && !changes[:is_public][1] CacheAsyncClearJob.perform_later('project_rank_service', self.id) end + if !changes[:is_public][0] && changes[:is_public][1] + $redis_cache.srem("v2-project-rank-deleted", self.id) + end end end From 9ba00b21c9f3241a3738c8694fbe740542514d68 Mon Sep 17 00:00:00 2001 From: xiaoxiaoqiong Date: Thu, 17 Feb 2022 18:28:32 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E9=80=9A=E7=9F=A5api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/notices_controller.rb | 21 + app/jobs/send_template_message_job.rb | 8 + app/models/message_template.rb | 5 + .../message_template/competition_begin.rb | 35 + .../message_template/competition_result.rb | 35 + .../message_template/competition_view.rb | 35 + config/routes.rb | 1923 +++++++++-------- 7 files changed, 1101 insertions(+), 961 deletions(-) create mode 100644 app/controllers/notices_controller.rb create mode 100644 app/models/message_template/competition_begin.rb create mode 100644 app/models/message_template/competition_result.rb create mode 100644 app/models/message_template/competition_view.rb diff --git a/app/controllers/notices_controller.rb b/app/controllers/notices_controller.rb new file mode 100644 index 000000000..057c52224 --- /dev/null +++ b/app/controllers/notices_controller.rb @@ -0,0 +1,21 @@ +class NoticesController < ApplicationController + + def create + tip_exception("参数有误") if params["source"].blank? + user_id = params[:user_id] + + if params["source"] == "CompetitionBegin" + competition_id = params[:competition_id] + SendTemplateMessageJob.perform_later('CompetitionBegin', user_id, competition_id) + elsif params["source"] == "CompetitionResult" + competition_id = params[:competition_id] + SendTemplateMessageJob.perform_later('CompetitionResult', user_id, competition_id) + elsif params["source"] == "CompetitionView" + competition_id = params[:competition_id] + SendTemplateMessageJob.perform_later('CompetitionView', user_id, competition_id) + else + tip_exception("#{params["source"]}未配置") + end + render_ok + end +end diff --git a/app/jobs/send_template_message_job.rb b/app/jobs/send_template_message_job.rb index de75024dd..4c20a05b1 100644 --- a/app/jobs/send_template_message_job.rb +++ b/app/jobs/send_template_message_job.rb @@ -326,6 +326,14 @@ class SendTemplateMessageJob < ApplicationJob receivers_email_string, email_title, email_content = MessageTemplate::TeamLeft.get_email_message_content(receiver, organization, team) Notice::Write::EmailCreateService.call(receivers_email_string, email_title, email_content) end + when 'CompetitionBegin' + user_id, competition_id = args[0], args[1] + user = User.find_by_id(user_id) + project = Project.find_by_sql("select *,title as name from competitions where id=#{competition_id}") + return unless user.present? && project.present? + receivers = User.where(id: user_id) + receivers_string, content, notification_url = MessageTemplate::TeamLeft.get_message_content(receivers, nil, nil) + Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {user_id: user_id, competition_name: project.first&.name, identifier: project.first&.identifier}) end end end \ No newline at end of file diff --git a/app/models/message_template.rb b/app/models/message_template.rb index 13864184a..25f9d06d8 100644 --- a/app/models/message_template.rb +++ b/app/models/message_template.rb @@ -74,6 +74,11 @@ class MessageTemplate < ApplicationRecord self.create(type: 'MessageTemplate::TeamJoined', sys_notice: '你已被拉入组织 {organization}{team} 团队,拥有{role}权限', email: email_html, email_title: "#{PLATFORM}: 在 {organization} 组织你的账号有权限变更", notification_url: '{baseurl}/{login}') email_html = File.read("#{email_template_html_dir}/team_left.html") self.create(type: 'MessageTemplate::TeamLeft', sys_notice: '你已被移出组织 {organization}{team} 团队', email: email_html, email_title: "#{PLATFORM}: 在 {organization} 组织你的账号有权限变更", notification_url: '{baseurl}/{login}') + + # 竞赛通知 + self.create(type: 'MessageTemplate::CompetitionBegin', sys_notice: '你报名的竞赛 {competition_name} 已进入比赛进行阶段,可在此期间提交作品', notification_url: '{to_url}') + self.create(type: 'MessageTemplate::CompetitionResult', sys_notice: '你报名的竞赛 {competition_name} 已进入成绩公示阶段,可查看排行榜信息', notification_url: '{to_url}') + self.create(type: 'MessageTemplate::CompetitionView', sys_notice: '你报名的竞赛 {competition_name} 距作品提交结束日期仅剩3天,若尚未提交参赛作品,请尽快提交', notification_url: '{to_url}') end def self.sys_notice diff --git a/app/models/message_template/competition_begin.rb b/app/models/message_template/competition_begin.rb new file mode 100644 index 000000000..b521d7455 --- /dev/null +++ b/app/models/message_template/competition_begin.rb @@ -0,0 +1,35 @@ +# == Schema Information +# +# Table name: message_templates +# +# id :integer not null, primary key +# type :string(255) +# sys_notice :text(65535) +# email :text(65535) +# created_at :datetime not null +# updated_at :datetime not null +# notification_url :string(255) +# email_title :string(255) +# + +# 报名的竞赛进入比赛进行阶段 +# 触发场景 +# 赛队成员报名的竞赛已进入比赛进行阶段 +# 通知文案格式 +# 你报名的竞赛 xxx 已进入比赛进行阶段,可在此阶段提交作品 +# 时间:x分钟/小时/天/月前 +# 通知文案示例 +# 你报名的竞赛 代码审查大赛 已进入比赛进行阶段,可在此期间提交作品 +# 时间:3小时前 +# 点击通知跳转页面 +# 点击此通知将跳转到代码审查大赛详情页: +# http://117.50.100.12:8080/competitions/lgw7st/home +class MessageTemplate::CompetitionBegin < MessageTemplate + + # MessageTemplate::FollowedTip.get_message_content(User.where(login: 'yystopf'), User.last) + def self.get_message_content(receivers, competition) + return receivers_string(receivers), sys_notice.to_s.gsub('{competition_name}', competition&.name), notification_url.to_s.gsub('{to_url}', "/competitions/#{competition.identifier}/home") + # rescue + # return '', '', '' + end +end diff --git a/app/models/message_template/competition_result.rb b/app/models/message_template/competition_result.rb new file mode 100644 index 000000000..c949a38cf --- /dev/null +++ b/app/models/message_template/competition_result.rb @@ -0,0 +1,35 @@ +# == Schema Information +# +# Table name: message_templates +# +# id :integer not null, primary key +# type :string(255) +# sys_notice :text(65535) +# email :text(65535) +# created_at :datetime not null +# updated_at :datetime not null +# notification_url :string(255) +# email_title :string(255) +# + +# 报名的竞赛进入成绩公示阶段 +# 触发场景 +# 赛队成员报名的竞赛已进入成绩公示阶段 +# 通知文案格式 +# 你报名的竞赛 xxx 已进入成绩公示阶段,可查看排行榜信息 +# 时间:x分钟/小时/天/月前 +# 通知文案示例 +# 你报名的竞赛 代码审查大赛 已进入成绩公示阶段,可查看排行榜信息 +# 时间:3小时前 +# 点击通知跳转页面 +# 点击此通知将跳转到代码审查大赛详情页: +# http://117.50.100.12:8080/competitions/lgw7st/home +class MessageTemplate::CompetitionResult < MessageTemplate + + # MessageTemplate::FollowedTip.get_message_content(User.where(login: 'yystopf'), User.last) + def self.get_message_content(receivers, competition) + return receivers_string(receivers), sys_notice.gsub('{competition_name}', competition&.title), notification_url.gsub('{to_url}', "/competitions/#{competition.identifier}/home") + rescue + return '', '', '' + end +end diff --git a/app/models/message_template/competition_view.rb b/app/models/message_template/competition_view.rb new file mode 100644 index 000000000..d669d7fda --- /dev/null +++ b/app/models/message_template/competition_view.rb @@ -0,0 +1,35 @@ +# == Schema Information +# +# Table name: message_templates +# +# id :integer not null, primary key +# type :string(255) +# sys_notice :text(65535) +# email :text(65535) +# created_at :datetime not null +# updated_at :datetime not null +# notification_url :string(255) +# email_title :string(255) +# + +# 报名的竞赛比赛结束时间临近 +# 触发场景 +# 赛队成员报名的竞赛阶段处于比赛进行中,且距比赛结束日期仅剩3天 +# 通知文案格式 +# 你报名的竞赛 xxx 距作品提交结束日期仅剩3天,若尚未提交参赛作品,请尽快提交 +# 时间:x分钟/小时/天/月前 +# 通知文案示例 +# 你报名的竞赛 代码审查大赛 距作品提交结束日期仅剩3天,若尚未提交参赛作品,请尽快提交 +# 时间:3小时前 +# 点击通知跳转页面 +# 点击此通知将跳转到代码审查大赛详情页: +# http://117.50.100.12:8080/competitions/lgw7st/home +class MessageTemplate::CompetitionView < MessageTemplate + + # MessageTemplate::FollowedTip.get_message_content(User.where(login: 'yystopf'), User.last) + def self.get_message_content(receivers, competition) + return receivers_string(receivers), sys_notice.gsub('{competition_name}', competition&.title), notification_url.gsub('{to_url}', "/competitions/#{competition.identifier}/home") + rescue + return '', '', '' + end +end diff --git a/config/routes.rb b/config/routes.rb index be87e7e68..7e280820a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,961 +1,962 @@ -Rails.application.routes.draw do - - require 'sidekiq/web' - require 'sidekiq/cron/web' - require 'admin_constraint' - - # mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new - - # Serve websocket cable requests in-process - mount ActionCable.server => '/cable' - - get 'attachments/entries/get_file', to: 'attachments#get_file' - get 'attachments/download/:id', to: 'attachments#show' - get 'attachments/download/:id/:filename', to: 'attachments#show' - - get 'auth/qq/callback', to: 'oauth/qq#create' - get 'auth/failure', to: 'oauth/base#auth_failure' - get 'auth/cas/callback', to: 'oauth/cas#create' - - get 'oauth/bind', to: 'oauth/educoder#bind' - get 'oauth/register', to: 'oauth#register' - post 'oauth/auto_register', to: 'oauth#auto_register' - - resources :edu_settings - - scope '/api' do - namespace :ci do - resources :languages, only: [:index, :show] do - collection do - get :common - end - end - - resources :templates, only: [:list,:templates_by_stage,:create,:update,:destroy,:show] do - collection do - get :list - get :templates_by_stage - end - end - - resources :secrets do - end - - resources :pipelines do - collection do - get :list - end - member do - get :content - get :stages - post :create_stage - post :create_trustie_pipeline - delete :delete_stage, :path => ":stage_id/delete_stage", to: 'pipelines#delete_stage' - put :update_stage, :path => ":stage_id/update_stage", to: 'pipelines#update_stage' - get :stage_steps, :path => ":stage_id/steps", to: 'pipelines#steps' - post :create_stage_step, :path => ":stage_id/create_step", to: 'pipelines#create_stage_step' - post :stage_step, :path => ":stage_id/stage_step", to: 'pipelines#stage_step' - delete :delete_stage_step, :path => ":stage_id/:step_id/delete_step", to: 'pipelines#delete_stage_step' - put :update_stage_step, :path => ":stage_id/update_step", to: 'pipelines#update_stage_step' - end - end - - # resources :repos, only: :index do - # collection do - # get 'get_trustie_pipeline', to: 'builds#get_trustie_pipeline', as: 'get_trustie_pipeline' - # get ':number', to: 'builds#detail', as: 'detail' - # post ':number', to: 'builds#restart', as: 'restart' - # delete ':number', to: 'builds#delete', as: 'delete' - # get ':number/logs/:stage/:step', to: 'builds#logs', as: 'logs' - # end - # end - end - - resources :public_keys, only: [:index, :create, :destroy] - - resources :project_rank, only: [:index] - resources :user_rank, only: [:index] - - resources :statistic, only: [:index] do - collection do - get :platform_profile - get :platform_code - get :active_project_rank - get :active_developer_rank - end - end - resources :sync_forge, only: [:create] do - collection do - post :sync_users - post :sync_range_projects - end - end - resources :composes do - resources :compose_projects, only: [:create, :destroy] - end - resources :attachments do - member do - post :preview_attachment - end - collection do - delete :destroy_files - end - end - get 'home/index' - get 'home/search' - get 'main/first_stamp' - - get 'search', to: 'searchs#index' - put 'commons/hidden', to: 'commons#hidden' - put 'commons/unhidden', to: 'commons#unhidden' - delete 'commons/delete', to: 'commons#delete' - - resources :owners, only: [:index, :show] - - scope module: :organizations do - resources :organizations, except: [:edit, :new] do - resources :organization_users, only: [:index, :destroy] do - collection do - delete :quit - end - end - resources :teams, except: [:edit, :new] do - collection do - get :search - end - resources :team_users, only: [:index, :create, :destroy] do - collection do - delete :quit - end - end - resources :team_projects, only: [:index, :create, :destroy] do ;end - end - resources :projects, only: [:index] do - collection do - get :search - end - end - get :recommend, on: :collection - end - end - - resources :issues, except: [:index, :new,:create, :update, :edit, :destroy] do - resources :journals, only: [:index, :create, :destroy, :edit, :update] do - member do - get :get_children_journals - end - end - resources :issue_times, only: [:create] do - collection do - post :end_work - end - end - resources :issue_depends, only: [:create, :destroy] - end - - resources :template_message_settings, only: [:index] - - resources :applied_projects, only: [:create] - - resources :project_categories, only: [:index, :show] do - get :group_list, on: :collection - get :pinned_index, on: :collection - end - resources :project_languages, only: [:index, :show] - resources :ignores, only: [:index, :show] - resources :licenses, only: [:index, :show] - - resources :watchers, only: [:index] do - collection do - post :follow - delete :unfollow - get :check_watch - end - end - resources :projects do - resources :praise_tread, only: [:index] do - collection do - post :like - delete :unlike - get :check_like - end - end - - collection do - post :migrate - get :group_type_list - get :recommend - get :banner_recommend - end - end - - resources :accounts do - collection do - post :login - post :register - post :reset_password - get :logout - get :get_verification_code - get :valid_email_and_phone - post :remote_register - post :remote_update - post :remote_login - post :remote_password - post :change_password - post :check - end - end - - resources :users do - member do - get :homepage_info - get :projects - get :watch_users - get :fan_users - get :hovercard - put :update_image - end - collection do - post :following - post :unfollow - get :get_user_info - get :attachment_show - get :html_show - get :get_navigation_info - post :reply_message - get :search_user_projects - post :brief_introduction - post :attendance - get :system_update - get :me - get :list - post :sync_token - post :sync_gitea_pwd - post :sync_salt - get :trustie_projects - get :trustie_related_projects - post :sync_user_info - - scope '/ci', module: :ci do - scope do - post( - '/cloud_account/bind', - to: 'cloud_accounts#bind', - as: :bind_cloud_acclount - ) - - post( - '/cloud_account/trustie_bind', - to: 'cloud_accounts#trustie_bind', - as: :trustie_bind_cloud_acclount - ) - - get( - '/cloud_account', - to: 'cloud_accounts#show', - as: :get_cloud_account - ) - - delete( - '/cloud_account/unbind', - to: 'cloud_accounts#unbind', - as: :unbind_cloud_acclount - ) - - get( - 'oauth_grant', - to: 'cloud_accounts#oauth_grant', - as: :ci_oauth_grant - ) - end - end - end - - scope module: :users do - get 'template_message_settings', to: 'template_message_settings#current_setting' - post 'template_message_settings/update_setting', to: 'template_message_settings#update_setting' - resources :system_notification_histories, only: [:create] - resources :applied_messages, only: [:index] - resources :applied_transfer_projects, only: [:index] do - member do - post :accept - post :refuse - end - end - resources :applied_projects, only: [:index] do - member do - post :accept - post :refuse - end - end - resources :headmaps, only: [:index] - resources :is_pinned_projects, only: [:index, :update] do - collection do - post :pin - end - end - resources :statistics, only: [:index] do - collection do - get :activity - get :develop - get :role - get :major - end - end - resources :project_trends, only: [:index] - resources :organizations, only: [:index] - # resources :projects, only: [:index] - # resources :subjects, only: [:index] - resources :project_packages, only: [:index] - # 私信 - # resources :private_messages, only: [:index, :create, :destroy] - # resources :recent_contacts, only: [:index] - # resource :private_message_details, only: [:show] - # resource :unread_message_info, only: [:show] - - # 通知中心 - resources :messages, only: [:index, :create] do - collection do - post :read - - end - end - delete 'messages', to: 'messages#delete' - end - - resources :tidings, only: [:index] - - scope module: :users do - resource :interest, only: [:create] - - resources :accounts, only: [:show, :update] do - resource :phone_bind, only: [:create] - resource :email_bind, only: [:create] - resource :password, only: [:update] - resource :avatar, only: [:update] - resource :auth_attachment, only: [:create] - resource :authentication_apply, only: [:create, :destroy] - resource :professional_auth_apply, only: [:create, :destroy] - resources :open_users, only: [:destroy] - end - end - end - - resources :users_for_private_messages, only: [:index] - - resources :files, only: [:index, :show, :update] do - collection do - delete :bulk_delete - put :bulk_move - post :bulk_send - put :bulk_public - get :public_with_course_and_project - get :mine_with_course_and_project - post :import - post :upload - put :bulk_publish - end - member do - get :histories - end - end - - namespace :wechats do - resource :js_sdk_signature, only: [:create] - end - - resource :template, only: [:show] - resource :setting, only: [:show] - - get '/auth/qq/callback', to: 'oauth/qq#create' - get '/auth/wechat/callback', to: 'oauth/wechat#create' - get '/auth/educoder/callback', to: 'oauth/educoder#create' - resource :bind_user, only: [:create] - - resources :hot_keywords, only: [:index] - - namespace :weapps do - resource :home, only: [:show] - resource :session, only: [:create] - resource :register, only: [:create] - resource :verification_code, only: [:create] - resource :code_session, only: [:create] - resource :verify, only: [:create] - resource :check_account, only: [:create] - resource :unbind_accounts, only: [:show, :destroy] - - resources :searchs, only: [:index] - resources :course_stickies, only: [:create] do - post :cancel_sticky, on: :collection - end - - resources :shixun_lists, only: [:index] - resources :subjects, path: :paths, only: [:index, :create, :update, :edit, :show] - resources :challenges do - get :is_play, on: :member - end - - resources :courses, only: [:create, :update, :edit, :show] do - member do - get :shixun_homework_category - get :teachers - get :students - get :course_groups - get :basic_info - get :course_activities - post :change_member_roles - delete :delete_course_teachers - delete :delete_course_students - end - - collection do - get :check_invite_code - end - end - end - - # Project Area START - scope "/:owner/:repo" do - scope do - get( - '/activity', - to: 'project_trends#index', - as: :project_activity - ) - end - - resource :projects, path: '/', except: [:show, :edit] do - member do - get :menu_list - get :branches - get :branches_slice - get :simple - get :watchers, to: 'projects#watch_users' - get :stargazers, to: 'projects#praise_users' - get :forks, to: 'projects#fork_users' - match :about, :via => [:get, :put, :post] - end - end - - resource :repositories, path: '/', only: [:show, :create, :edit] do - member do - get :files - get :detail - get :entries - match :sub_entries, :via => [:get, :put] - get :commits - get :commits_slice - get :tags - get :contributors - post :create_file - put :update_file - delete :delete_file - post :repo_hook - post :sync_mirror - get :top_counts - get 'commits/:sha', to: 'repositories#commit', as: 'commit' - get 'readme' - get 'languages' - get 'archive/:archive', to: 'repositories#archive', as: "archive", constraints: { archive: /.+/, format: /(zip|gzip)/ } - get 'raw', to: 'repositories#raw', as: "raw" - end - end - - # protected_branches - scope do - get( - '/protected_branches/', - to: 'protected_branches#index' - ) - get( - '/protected_branches/:branch_name', - to: 'protected_branches#show' - ) - get( - '/protected_branches/:branch_name/edit', - to: 'protected_branches#edit' - ) - delete( - '/protected_branches/:branch_name', - to: 'protected_branches#destroy' - ) - post( - '/protected_branches', - to: 'protected_branches#create' - ) - patch( - '/protected_branches/:branch_name', - to: 'protected_branches#update' - ) - end - - resources :issues do - collection do - get :commit_issues - get :index_chosen - post :clean - post :series_update - end - member do - post :copy - post :close_issue - post :lock_issue - end - end - - # compare - resources :compare, only: [:index, :create] - get '/compare/:base...:head' => 'compare#show', :as => 'compare', - :constraints => { base: /.+/, head: /.+/ } - - resources :pull_requests, :path => :pulls, except: [:destroy] do - member do - post :pr_merge - # post :check_merge - post :refuse_merge - get :files - get :commits - end - collection do - post :check_can_merge - get :create_merge_infos - get :get_branches - end - end - - resources :versions, :path => :milestones do - member do - post :update_status - end - end - - resources :members, :path => :collaborators, only: [:index, :create] do - collection do - delete :remove - put :change_role - end - end - - resources :hooks - resources :forks, only: [:create] - resources :project_trends, :path => :activity, only: [:index, :create] - resources :issue_tags, :path => :labels, only: [:create, :edit, :update, :destroy, :index] - resources :version_releases, :path => :releases, only: [:index,:new, :show, :create, :edit, :update, :destroy] - - scope module: :ci do - scope do - match( - 'ci_authorize', - to: 'projects#authorize', - as: :ci_authorize, - :via => [:get, :put] - ) - get( - 'get_trustie_pipeline', - to: 'projects#get_trustie_pipeline', - as: :get_trustie_pipeline - ) - put( - 'update_trustie_pipeline', - to: 'projects#update_trustie_pipeline', - as: :update_trustie_pipeline - ) - post( - 'activate', - to: 'projects#activate', - as: :ci_activate_project - ) - delete( - 'deactivate', - to: 'projects#deactivate', - as: :ci_deactivate_project - ) - end - - resources :cloud_accounts, only: [:create] do - member do - post :activate - delete :deactivate - end - end - resources :builds, param: :build do - member do - post :restart - delete :stop - get '/logs/:stage/:step', to: 'builds#logs', as: 'logs' - end - end - end - - scope module: :projects do - resources :members, only: [:index] - resources :teams, only: [:index, :create, :destroy] - resources :project_units, only: [:index, :create] - resources :applied_transfer_projects, only: [:create] do - collection do - get :organizations - post :cancel - end - end - resources :webhooks, except: [:show, :new] do - member do - get :tasks - post :test - end - end - scope do - get( - '/blob/*id/diff', - to: 'blob#diff', - constraints: { id: /.+/, format: false }, - as: :blob_diff - ) - get( - '/blob/*id', - to: 'blob#show', - constraints: { id: /.+/, format: false }, - as: :blob - ) - delete( - '/blob/*id', - to: 'blob#destroy', - constraints: { id: /.+/, format: false } - ) - put( - '/blob/*id', - to: 'blob#update', - constraints: { id: /.+/, format: false } - ) - post( - '/blob/*id', - to: 'blob#create', - constraints: { id: /.+/, format: false } - ) - end - - scope do - get( - '/raw/*id', - to: 'raw#show', - constraints: { id: /.+/, format: /(html|js)/ }, - as: :raw - ) - end - - scope do - get( - '/blame/*id', - to: 'blame#show', - constraints: { id: /.+/, format: /(html|js)/ }, - as: :blame - ) - end - - scope do - get( - '/tree/*id', - to: 'tree#show', - constraints: { id: /.+/, format: /(html|js)/ }, - as: :tree - ) - end - end - end - # Project Area END - - scope module: :helps do - resources :faqs, only: [:index] - end - end - - namespace :admins do - mount Sidekiq::Web => '/sidekiq' - get '/', to: 'dashboards#index' - resources :project_statistics, only: [:index] do - collection do - get :visits_static - end - end - resources :sites - resources :edu_settings - resources :project_languages - resources :project_categories - resources :project_licenses - resources :project_ignores - resources :reversed_keywords - resources :system_notifications do - member do - get :history - end - end - resources :message_templates, only: [:index, :edit, :update] do - collection do - get :init_data - end - end - resources :major_informations, only: [:index] - resources :ec_templates, only: [:index, :destroy] do - collection do - post :create_template - end - end - resources :graduation_standards, only: [:index, :destroy] do - collection do - post :create_standard - end - end - resources :auth_schools, only: [:index, :destroy] do - collection do - get :search_school - post :add_school - get :search_manager - post :add_manager - post :remove_manager - end - - end - resources :dashboards, only: [:index] do - collection do - get :month_active_user - get :evaluate - end - end - resources :files, only: [:create] - - resources :daily_school_statistics, only: [:index] do - get :export, on: :collection - end - - resources :school_statistics, only: [:index] do - get :contrast, on: :collection - end - - resources :users, only: [:index, :edit, :update, :destroy] do - member do - post :reward_grade - post :lock - post :unlock - post :active - post :reset_login_times - end - end - resource :import_disciplines, only: [:create] - resource :import_users, only: [:create] - resource :import_course_members, only: [:create] - resources :user_statistics, only: [:index] do - get :export, on: :collection - end - resources :library_applies, only: [:index] do - member do - post :agree - post :refuse - end - end - resources :video_applies, only: [:index] do - member do - post :agree - post :refuse - end - end - resources :identity_authentications, only: [:index] do - member do - post :agree - post :refuse - post :revoke - end - - collection do - post :batch_agree - end - end - resources :professional_authentications, only: [:index] do - member do - post :agree - post :refuse - post :revoke - end - - collection do - post :batch_agree - end - end - resources :shixun_authorizations, only: [:index] do - member do - post :agree - post :refuse - end - end - resources :subject_authorizations, only: [:index] do - member do - post :agree - post :refuse - end - end - resources :project_package_applies, only: [:index] do - member do - post :agree - post :refuse - end - end - resources :item_authentications, only: [:index, :show] do - member do - post :agree - post :refuse - end - end - resources :examination_authentications, only: [:index] do - member do - post :agree - post :refuse - end - end - resources :shixuns, only: [:index,:destroy] - resources :shixun_settings, only: [:index,:update] do - post :update_tag_repertoires, on: :member - end - resources :shixun_feedback_messages, only: [:index] - resources :shixun_recycles, only: [:index, :destroy] do - post :resume, on: :member - end - resources :shixun_modify_records, only: [:index] - resources :department_applies,only: [:index,:destroy] do - collection do - post :merge - end - member do - post :agree - end - end - resources :unit_applies,only: [:index,:destroy,:edit,:update] do - member do - post :agree - end - end - resources :mirror_repositories, only: [:index, :new, :create, :edit, :update, :destroy] do - collection do - post :merge - get :for_select - end - resources :mirror_scripts, only: [:index, :new, :create, :edit, :update, :destroy] - end - resources :choose_mirror_repositories, only: [:new, :create] - resources :schools, only: [:index, :destroy] - resources :departments, only: [:index, :create, :edit, :update, :destroy] do - resource :department_member, only: [:create, :destroy] - post :merge, on: :collection - end - - resource :about, only: [:edit, :update] - resource :agreement, only: [:edit, :update] - resource :help_center, only: [:edit, :update] - resource :contact_us, only: [:edit, :update] do - patch :update_address, on: :collection - end - resources :cooperatives, only: [:index, :create, :update, :destroy] do - post :drag, on: :collection - post :replace_image_url, on: :member - end - resources :faqs - resources :laboratories, only: [:index, :create, :destroy, :update] do - member do - get :shixuns_for_select - get :subjects_for_select - get :synchronize_user - post :update_sync_course - end - - resource :laboratory_setting, only: [:show, :update, :new] - resource :laboratory_user, only: [:create, :destroy] - - resources :carousels, only: [:index, :create, :update, :destroy] do - post :drag, on: :collection - end - - resources :laboratory_shixuns, only: [:index, :create, :destroy] do - member do - post :homepage - post :cancel_homepage - end - end - resources :laboratory_subjects, only: [:index, :create, :destroy] do - member do - post :homepage - post :cancel_homepage - end - end - end - - resources :weapp_carousels, only: [:index, :create, :update, :destroy] do - post :drag, on: :collection - end - resources :weapp_adverts, only: [:index, :create, :update, :destroy] do - post :drag, on: :collection - end - - resources :subject_settings, only: [:index, :update] do - post :update_mobile_show, on: :collection - end - - resources :subjects, only: [:index, :edit, :update, :destroy] do - member do - post :hide - post :cancel_hide - post :homepage_show - post :cancel_homepage_show - post :excellent - post :cancel_excellent - end - end - - resources :partners, only: [:index, :create, :destroy] do - resources :customers, only: [:index, :create, :destroy] - end - - resources :course_lists, only: [:index, :destroy] do - post :merge, on: :collection - end - - resources :courses, only: [:index, :destroy, :update] - - resources :projects, only: [:index, :edit, :update, :destroy] - - resources :disciplines, only: [:index, :create, :edit, :update, :destroy] do - post :adjust_position, on: :member - end - resources :sub_disciplines, only: [:index, :create, :edit, :update, :destroy] do - post :adjust_position, on: :member - end - resources :tag_disciplines, only: [:index, :create, :edit, :update, :destroy] do - post :adjust_position, on: :member - end - - resources :repertoires, only: [:index, :create, :edit, :update, :destroy] - resources :sub_repertoires, only: [:index, :create, :edit, :update, :destroy] - resources :tag_repertoires, only: [:index, :create, :edit, :update, :destroy] - - resources :salesmans, only: [:index, :create, :edit, :update, :destroy] do - post :batch_add, on: :collection - end - resources :salesman_channels, only: [:index, :create, :edit, :update, :destroy] do - post :batch_add, on: :collection - end - resources :salesman_customers, only: [:index, :create, :edit, :update, :destroy] do - post :batch_add, on: :collection - end - end - - - #git 认证回调 - match 'gitauth/*url', to: 'gits#auth', via: :all - - get 'oauth/get_code', to: 'oauth#get_code' - get 'oauth/get_token_callback', to: 'oauth#get_token_callback' - - root 'main#index' - - - ## react用 - get '*path', to: 'main#index', constraints: ReactConstraint.new - - -end +Rails.application.routes.draw do + + require 'sidekiq/web' + require 'sidekiq/cron/web' + require 'admin_constraint' + + # mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new + + # Serve websocket cable requests in-process + mount ActionCable.server => '/cable' + + get 'attachments/entries/get_file', to: 'attachments#get_file' + get 'attachments/download/:id', to: 'attachments#show' + get 'attachments/download/:id/:filename', to: 'attachments#show' + + get 'auth/qq/callback', to: 'oauth/qq#create' + get 'auth/failure', to: 'oauth/base#auth_failure' + get 'auth/cas/callback', to: 'oauth/cas#create' + + get 'oauth/bind', to: 'oauth/educoder#bind' + get 'oauth/register', to: 'oauth#register' + post 'oauth/auto_register', to: 'oauth#auto_register' + + resources :edu_settings + + scope '/api' do + namespace :ci do + resources :languages, only: [:index, :show] do + collection do + get :common + end + end + + resources :templates, only: [:list,:templates_by_stage,:create,:update,:destroy,:show] do + collection do + get :list + get :templates_by_stage + end + end + + resources :secrets do + end + + resources :pipelines do + collection do + get :list + end + member do + get :content + get :stages + post :create_stage + post :create_trustie_pipeline + delete :delete_stage, :path => ":stage_id/delete_stage", to: 'pipelines#delete_stage' + put :update_stage, :path => ":stage_id/update_stage", to: 'pipelines#update_stage' + get :stage_steps, :path => ":stage_id/steps", to: 'pipelines#steps' + post :create_stage_step, :path => ":stage_id/create_step", to: 'pipelines#create_stage_step' + post :stage_step, :path => ":stage_id/stage_step", to: 'pipelines#stage_step' + delete :delete_stage_step, :path => ":stage_id/:step_id/delete_step", to: 'pipelines#delete_stage_step' + put :update_stage_step, :path => ":stage_id/update_step", to: 'pipelines#update_stage_step' + end + end + + # resources :repos, only: :index do + # collection do + # get 'get_trustie_pipeline', to: 'builds#get_trustie_pipeline', as: 'get_trustie_pipeline' + # get ':number', to: 'builds#detail', as: 'detail' + # post ':number', to: 'builds#restart', as: 'restart' + # delete ':number', to: 'builds#delete', as: 'delete' + # get ':number/logs/:stage/:step', to: 'builds#logs', as: 'logs' + # end + # end + end + + resources :public_keys, only: [:index, :create, :destroy] + + resources :project_rank, only: [:index] + resources :user_rank, only: [:index] + + resources :statistic, only: [:index] do + collection do + get :platform_profile + get :platform_code + get :active_project_rank + get :active_developer_rank + end + end + resources :sync_forge, only: [:create] do + collection do + post :sync_users + post :sync_range_projects + end + end + resources :composes do + resources :compose_projects, only: [:create, :destroy] + end + resources :attachments do + member do + post :preview_attachment + end + collection do + delete :destroy_files + end + end + get 'home/index' + get 'home/search' + get 'main/first_stamp' + + get 'search', to: 'searchs#index' + put 'commons/hidden', to: 'commons#hidden' + put 'commons/unhidden', to: 'commons#unhidden' + delete 'commons/delete', to: 'commons#delete' + + resources :owners, only: [:index, :show] + + scope module: :organizations do + resources :organizations, except: [:edit, :new] do + resources :organization_users, only: [:index, :destroy] do + collection do + delete :quit + end + end + resources :teams, except: [:edit, :new] do + collection do + get :search + end + resources :team_users, only: [:index, :create, :destroy] do + collection do + delete :quit + end + end + resources :team_projects, only: [:index, :create, :destroy] do ;end + end + resources :projects, only: [:index] do + collection do + get :search + end + end + get :recommend, on: :collection + end + end + + resources :issues, except: [:index, :new,:create, :update, :edit, :destroy] do + resources :journals, only: [:index, :create, :destroy, :edit, :update] do + member do + get :get_children_journals + end + end + resources :issue_times, only: [:create] do + collection do + post :end_work + end + end + resources :issue_depends, only: [:create, :destroy] + end + + resources :template_message_settings, only: [:index] + + resources :applied_projects, only: [:create] + + resources :project_categories, only: [:index, :show] do + get :group_list, on: :collection + get :pinned_index, on: :collection + end + resources :project_languages, only: [:index, :show] + resources :ignores, only: [:index, :show] + resources :licenses, only: [:index, :show] + + resources :watchers, only: [:index] do + collection do + post :follow + delete :unfollow + get :check_watch + end + end + resources :projects do + resources :praise_tread, only: [:index] do + collection do + post :like + delete :unlike + get :check_like + end + end + + collection do + post :migrate + get :group_type_list + get :recommend + get :banner_recommend + end + end + + resources :accounts do + collection do + post :login + post :register + post :reset_password + get :logout + get :get_verification_code + get :valid_email_and_phone + post :remote_register + post :remote_update + post :remote_login + post :remote_password + post :change_password + post :check + end + end + + resources :users do + member do + get :homepage_info + get :projects + get :watch_users + get :fan_users + get :hovercard + put :update_image + end + collection do + post :following + post :unfollow + get :get_user_info + get :attachment_show + get :html_show + get :get_navigation_info + post :reply_message + get :search_user_projects + post :brief_introduction + post :attendance + get :system_update + get :me + get :list + post :sync_token + post :sync_gitea_pwd + post :sync_salt + get :trustie_projects + get :trustie_related_projects + post :sync_user_info + + scope '/ci', module: :ci do + scope do + post( + '/cloud_account/bind', + to: 'cloud_accounts#bind', + as: :bind_cloud_acclount + ) + + post( + '/cloud_account/trustie_bind', + to: 'cloud_accounts#trustie_bind', + as: :trustie_bind_cloud_acclount + ) + + get( + '/cloud_account', + to: 'cloud_accounts#show', + as: :get_cloud_account + ) + + delete( + '/cloud_account/unbind', + to: 'cloud_accounts#unbind', + as: :unbind_cloud_acclount + ) + + get( + 'oauth_grant', + to: 'cloud_accounts#oauth_grant', + as: :ci_oauth_grant + ) + end + end + end + + scope module: :users do + get 'template_message_settings', to: 'template_message_settings#current_setting' + post 'template_message_settings/update_setting', to: 'template_message_settings#update_setting' + resources :system_notification_histories, only: [:create] + resources :applied_messages, only: [:index] + resources :applied_transfer_projects, only: [:index] do + member do + post :accept + post :refuse + end + end + resources :applied_projects, only: [:index] do + member do + post :accept + post :refuse + end + end + resources :headmaps, only: [:index] + resources :is_pinned_projects, only: [:index, :update] do + collection do + post :pin + end + end + resources :statistics, only: [:index] do + collection do + get :activity + get :develop + get :role + get :major + end + end + resources :project_trends, only: [:index] + resources :organizations, only: [:index] + # resources :projects, only: [:index] + # resources :subjects, only: [:index] + resources :project_packages, only: [:index] + # 私信 + # resources :private_messages, only: [:index, :create, :destroy] + # resources :recent_contacts, only: [:index] + # resource :private_message_details, only: [:show] + # resource :unread_message_info, only: [:show] + + # 通知中心 + resources :messages, only: [:index, :create] do + collection do + post :read + + end + end + delete 'messages', to: 'messages#delete' + end + + resources :tidings, only: [:index] + + scope module: :users do + resource :interest, only: [:create] + + resources :accounts, only: [:show, :update] do + resource :phone_bind, only: [:create] + resource :email_bind, only: [:create] + resource :password, only: [:update] + resource :avatar, only: [:update] + resource :auth_attachment, only: [:create] + resource :authentication_apply, only: [:create, :destroy] + resource :professional_auth_apply, only: [:create, :destroy] + resources :open_users, only: [:destroy] + end + end + end + + resources :users_for_private_messages, only: [:index] + + resources :files, only: [:index, :show, :update] do + collection do + delete :bulk_delete + put :bulk_move + post :bulk_send + put :bulk_public + get :public_with_course_and_project + get :mine_with_course_and_project + post :import + post :upload + put :bulk_publish + end + member do + get :histories + end + end + + namespace :wechats do + resource :js_sdk_signature, only: [:create] + end + + resource :template, only: [:show] + resource :setting, only: [:show] + + get '/auth/qq/callback', to: 'oauth/qq#create' + get '/auth/wechat/callback', to: 'oauth/wechat#create' + get '/auth/educoder/callback', to: 'oauth/educoder#create' + resource :bind_user, only: [:create] + + resources :hot_keywords, only: [:index] + resources :notices, only: [:create] + + namespace :weapps do + resource :home, only: [:show] + resource :session, only: [:create] + resource :register, only: [:create] + resource :verification_code, only: [:create] + resource :code_session, only: [:create] + resource :verify, only: [:create] + resource :check_account, only: [:create] + resource :unbind_accounts, only: [:show, :destroy] + + resources :searchs, only: [:index] + resources :course_stickies, only: [:create] do + post :cancel_sticky, on: :collection + end + + resources :shixun_lists, only: [:index] + resources :subjects, path: :paths, only: [:index, :create, :update, :edit, :show] + resources :challenges do + get :is_play, on: :member + end + + resources :courses, only: [:create, :update, :edit, :show] do + member do + get :shixun_homework_category + get :teachers + get :students + get :course_groups + get :basic_info + get :course_activities + post :change_member_roles + delete :delete_course_teachers + delete :delete_course_students + end + + collection do + get :check_invite_code + end + end + end + + # Project Area START + scope "/:owner/:repo" do + scope do + get( + '/activity', + to: 'project_trends#index', + as: :project_activity + ) + end + + resource :projects, path: '/', except: [:show, :edit] do + member do + get :menu_list + get :branches + get :branches_slice + get :simple + get :watchers, to: 'projects#watch_users' + get :stargazers, to: 'projects#praise_users' + get :forks, to: 'projects#fork_users' + match :about, :via => [:get, :put, :post] + end + end + + resource :repositories, path: '/', only: [:show, :create, :edit] do + member do + get :files + get :detail + get :entries + match :sub_entries, :via => [:get, :put] + get :commits + get :commits_slice + get :tags + get :contributors + post :create_file + put :update_file + delete :delete_file + post :repo_hook + post :sync_mirror + get :top_counts + get 'commits/:sha', to: 'repositories#commit', as: 'commit' + get 'readme' + get 'languages' + get 'archive/:archive', to: 'repositories#archive', as: "archive", constraints: { archive: /.+/, format: /(zip|gzip)/ } + get 'raw', to: 'repositories#raw', as: "raw" + end + end + + # protected_branches + scope do + get( + '/protected_branches/', + to: 'protected_branches#index' + ) + get( + '/protected_branches/:branch_name', + to: 'protected_branches#show' + ) + get( + '/protected_branches/:branch_name/edit', + to: 'protected_branches#edit' + ) + delete( + '/protected_branches/:branch_name', + to: 'protected_branches#destroy' + ) + post( + '/protected_branches', + to: 'protected_branches#create' + ) + patch( + '/protected_branches/:branch_name', + to: 'protected_branches#update' + ) + end + + resources :issues do + collection do + get :commit_issues + get :index_chosen + post :clean + post :series_update + end + member do + post :copy + post :close_issue + post :lock_issue + end + end + + # compare + resources :compare, only: [:index, :create] + get '/compare/:base...:head' => 'compare#show', :as => 'compare', + :constraints => { base: /.+/, head: /.+/ } + + resources :pull_requests, :path => :pulls, except: [:destroy] do + member do + post :pr_merge + # post :check_merge + post :refuse_merge + get :files + get :commits + end + collection do + post :check_can_merge + get :create_merge_infos + get :get_branches + end + end + + resources :versions, :path => :milestones do + member do + post :update_status + end + end + + resources :members, :path => :collaborators, only: [:index, :create] do + collection do + delete :remove + put :change_role + end + end + + resources :hooks + resources :forks, only: [:create] + resources :project_trends, :path => :activity, only: [:index, :create] + resources :issue_tags, :path => :labels, only: [:create, :edit, :update, :destroy, :index] + resources :version_releases, :path => :releases, only: [:index,:new, :show, :create, :edit, :update, :destroy] + + scope module: :ci do + scope do + match( + 'ci_authorize', + to: 'projects#authorize', + as: :ci_authorize, + :via => [:get, :put] + ) + get( + 'get_trustie_pipeline', + to: 'projects#get_trustie_pipeline', + as: :get_trustie_pipeline + ) + put( + 'update_trustie_pipeline', + to: 'projects#update_trustie_pipeline', + as: :update_trustie_pipeline + ) + post( + 'activate', + to: 'projects#activate', + as: :ci_activate_project + ) + delete( + 'deactivate', + to: 'projects#deactivate', + as: :ci_deactivate_project + ) + end + + resources :cloud_accounts, only: [:create] do + member do + post :activate + delete :deactivate + end + end + resources :builds, param: :build do + member do + post :restart + delete :stop + get '/logs/:stage/:step', to: 'builds#logs', as: 'logs' + end + end + end + + scope module: :projects do + resources :members, only: [:index] + resources :teams, only: [:index, :create, :destroy] + resources :project_units, only: [:index, :create] + resources :applied_transfer_projects, only: [:create] do + collection do + get :organizations + post :cancel + end + end + resources :webhooks, except: [:show, :new] do + member do + get :tasks + post :test + end + end + scope do + get( + '/blob/*id/diff', + to: 'blob#diff', + constraints: { id: /.+/, format: false }, + as: :blob_diff + ) + get( + '/blob/*id', + to: 'blob#show', + constraints: { id: /.+/, format: false }, + as: :blob + ) + delete( + '/blob/*id', + to: 'blob#destroy', + constraints: { id: /.+/, format: false } + ) + put( + '/blob/*id', + to: 'blob#update', + constraints: { id: /.+/, format: false } + ) + post( + '/blob/*id', + to: 'blob#create', + constraints: { id: /.+/, format: false } + ) + end + + scope do + get( + '/raw/*id', + to: 'raw#show', + constraints: { id: /.+/, format: /(html|js)/ }, + as: :raw + ) + end + + scope do + get( + '/blame/*id', + to: 'blame#show', + constraints: { id: /.+/, format: /(html|js)/ }, + as: :blame + ) + end + + scope do + get( + '/tree/*id', + to: 'tree#show', + constraints: { id: /.+/, format: /(html|js)/ }, + as: :tree + ) + end + end + end + # Project Area END + + scope module: :helps do + resources :faqs, only: [:index] + end + end + + namespace :admins do + mount Sidekiq::Web => '/sidekiq' + get '/', to: 'dashboards#index' + resources :project_statistics, only: [:index] do + collection do + get :visits_static + end + end + resources :sites + resources :edu_settings + resources :project_languages + resources :project_categories + resources :project_licenses + resources :project_ignores + resources :reversed_keywords + resources :system_notifications do + member do + get :history + end + end + resources :message_templates, only: [:index, :edit, :update] do + collection do + get :init_data + end + end + resources :major_informations, only: [:index] + resources :ec_templates, only: [:index, :destroy] do + collection do + post :create_template + end + end + resources :graduation_standards, only: [:index, :destroy] do + collection do + post :create_standard + end + end + resources :auth_schools, only: [:index, :destroy] do + collection do + get :search_school + post :add_school + get :search_manager + post :add_manager + post :remove_manager + end + + end + resources :dashboards, only: [:index] do + collection do + get :month_active_user + get :evaluate + end + end + resources :files, only: [:create] + + resources :daily_school_statistics, only: [:index] do + get :export, on: :collection + end + + resources :school_statistics, only: [:index] do + get :contrast, on: :collection + end + + resources :users, only: [:index, :edit, :update, :destroy] do + member do + post :reward_grade + post :lock + post :unlock + post :active + post :reset_login_times + end + end + resource :import_disciplines, only: [:create] + resource :import_users, only: [:create] + resource :import_course_members, only: [:create] + resources :user_statistics, only: [:index] do + get :export, on: :collection + end + resources :library_applies, only: [:index] do + member do + post :agree + post :refuse + end + end + resources :video_applies, only: [:index] do + member do + post :agree + post :refuse + end + end + resources :identity_authentications, only: [:index] do + member do + post :agree + post :refuse + post :revoke + end + + collection do + post :batch_agree + end + end + resources :professional_authentications, only: [:index] do + member do + post :agree + post :refuse + post :revoke + end + + collection do + post :batch_agree + end + end + resources :shixun_authorizations, only: [:index] do + member do + post :agree + post :refuse + end + end + resources :subject_authorizations, only: [:index] do + member do + post :agree + post :refuse + end + end + resources :project_package_applies, only: [:index] do + member do + post :agree + post :refuse + end + end + resources :item_authentications, only: [:index, :show] do + member do + post :agree + post :refuse + end + end + resources :examination_authentications, only: [:index] do + member do + post :agree + post :refuse + end + end + resources :shixuns, only: [:index,:destroy] + resources :shixun_settings, only: [:index,:update] do + post :update_tag_repertoires, on: :member + end + resources :shixun_feedback_messages, only: [:index] + resources :shixun_recycles, only: [:index, :destroy] do + post :resume, on: :member + end + resources :shixun_modify_records, only: [:index] + resources :department_applies,only: [:index,:destroy] do + collection do + post :merge + end + member do + post :agree + end + end + resources :unit_applies,only: [:index,:destroy,:edit,:update] do + member do + post :agree + end + end + resources :mirror_repositories, only: [:index, :new, :create, :edit, :update, :destroy] do + collection do + post :merge + get :for_select + end + resources :mirror_scripts, only: [:index, :new, :create, :edit, :update, :destroy] + end + resources :choose_mirror_repositories, only: [:new, :create] + resources :schools, only: [:index, :destroy] + resources :departments, only: [:index, :create, :edit, :update, :destroy] do + resource :department_member, only: [:create, :destroy] + post :merge, on: :collection + end + + resource :about, only: [:edit, :update] + resource :agreement, only: [:edit, :update] + resource :help_center, only: [:edit, :update] + resource :contact_us, only: [:edit, :update] do + patch :update_address, on: :collection + end + resources :cooperatives, only: [:index, :create, :update, :destroy] do + post :drag, on: :collection + post :replace_image_url, on: :member + end + resources :faqs + resources :laboratories, only: [:index, :create, :destroy, :update] do + member do + get :shixuns_for_select + get :subjects_for_select + get :synchronize_user + post :update_sync_course + end + + resource :laboratory_setting, only: [:show, :update, :new] + resource :laboratory_user, only: [:create, :destroy] + + resources :carousels, only: [:index, :create, :update, :destroy] do + post :drag, on: :collection + end + + resources :laboratory_shixuns, only: [:index, :create, :destroy] do + member do + post :homepage + post :cancel_homepage + end + end + resources :laboratory_subjects, only: [:index, :create, :destroy] do + member do + post :homepage + post :cancel_homepage + end + end + end + + resources :weapp_carousels, only: [:index, :create, :update, :destroy] do + post :drag, on: :collection + end + resources :weapp_adverts, only: [:index, :create, :update, :destroy] do + post :drag, on: :collection + end + + resources :subject_settings, only: [:index, :update] do + post :update_mobile_show, on: :collection + end + + resources :subjects, only: [:index, :edit, :update, :destroy] do + member do + post :hide + post :cancel_hide + post :homepage_show + post :cancel_homepage_show + post :excellent + post :cancel_excellent + end + end + + resources :partners, only: [:index, :create, :destroy] do + resources :customers, only: [:index, :create, :destroy] + end + + resources :course_lists, only: [:index, :destroy] do + post :merge, on: :collection + end + + resources :courses, only: [:index, :destroy, :update] + + resources :projects, only: [:index, :edit, :update, :destroy] + + resources :disciplines, only: [:index, :create, :edit, :update, :destroy] do + post :adjust_position, on: :member + end + resources :sub_disciplines, only: [:index, :create, :edit, :update, :destroy] do + post :adjust_position, on: :member + end + resources :tag_disciplines, only: [:index, :create, :edit, :update, :destroy] do + post :adjust_position, on: :member + end + + resources :repertoires, only: [:index, :create, :edit, :update, :destroy] + resources :sub_repertoires, only: [:index, :create, :edit, :update, :destroy] + resources :tag_repertoires, only: [:index, :create, :edit, :update, :destroy] + + resources :salesmans, only: [:index, :create, :edit, :update, :destroy] do + post :batch_add, on: :collection + end + resources :salesman_channels, only: [:index, :create, :edit, :update, :destroy] do + post :batch_add, on: :collection + end + resources :salesman_customers, only: [:index, :create, :edit, :update, :destroy] do + post :batch_add, on: :collection + end + end + + + #git 认证回调 + match 'gitauth/*url', to: 'gits#auth', via: :all + + get 'oauth/get_code', to: 'oauth#get_code' + get 'oauth/get_token_callback', to: 'oauth#get_token_callback' + + root 'main#index' + + + ## react用 + get '*path', to: 'main#index', constraints: ReactConstraint.new + + +end From 5ed7b3e4ad14c87b1344b5a38cb45e5212f04bc6 Mon Sep 17 00:00:00 2001 From: xiaoxiaoqiong Date: Mon, 21 Feb 2022 16:46:40 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=B0=83=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/notices_controller.rb | 4 +- app/jobs/send_template_message_job.rb | 18 ++++++++- ...petition_view.rb => competition_review.rb} | 2 +- lib/tasks/competition_notice.rake | 38 +++++++++++++++++++ 4 files changed, 58 insertions(+), 4 deletions(-) rename app/models/message_template/{competition_view.rb => competition_review.rb} (95%) create mode 100644 lib/tasks/competition_notice.rake diff --git a/app/controllers/notices_controller.rb b/app/controllers/notices_controller.rb index 057c52224..bf7eb21b1 100644 --- a/app/controllers/notices_controller.rb +++ b/app/controllers/notices_controller.rb @@ -10,9 +10,9 @@ class NoticesController < ApplicationController elsif params["source"] == "CompetitionResult" competition_id = params[:competition_id] SendTemplateMessageJob.perform_later('CompetitionResult', user_id, competition_id) - elsif params["source"] == "CompetitionView" + elsif params["source"] == "CompetitionReview" competition_id = params[:competition_id] - SendTemplateMessageJob.perform_later('CompetitionView', user_id, competition_id) + SendTemplateMessageJob.perform_later('CompetitionReview', user_id, competition_id) else tip_exception("#{params["source"]}未配置") end diff --git a/app/jobs/send_template_message_job.rb b/app/jobs/send_template_message_job.rb index 4c20a05b1..9cc819a11 100644 --- a/app/jobs/send_template_message_job.rb +++ b/app/jobs/send_template_message_job.rb @@ -332,7 +332,23 @@ class SendTemplateMessageJob < ApplicationJob project = Project.find_by_sql("select *,title as name from competitions where id=#{competition_id}") return unless user.present? && project.present? receivers = User.where(id: user_id) - receivers_string, content, notification_url = MessageTemplate::TeamLeft.get_message_content(receivers, nil, nil) + receivers_string, content, notification_url = MessageTemplate::CompetitionBegin.get_message_content(receivers, project.first) + Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {user_id: user_id, competition_name: project.first&.name, identifier: project.first&.identifier}) + when 'CompetitionReview' + user_id, competition_id = args[0], args[1] + user = User.find_by_id(user_id) + project = Project.find_by_sql("select *,title as name from competitions where id=#{competition_id}") + return unless user.present? && project.present? + receivers = User.where(id: user_id) + receivers_string, content, notification_url = MessageTemplate::CompetitionReview.get_message_content(receivers, project.first) + Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {user_id: user_id, competition_name: project.first&.name, identifier: project.first&.identifier}) + when 'CompetitionResult' + user_id, competition_id = args[0], args[1] + user = User.find_by_id(user_id) + project = Project.find_by_sql("select *,title as name from competitions where id=#{competition_id}") + return unless user.present? && project.present? + receivers = User.where(id: user_id) + receivers_string, content, notification_url = MessageTemplate::CompetitionResult.get_message_content(receivers, project.first) Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {user_id: user_id, competition_name: project.first&.name, identifier: project.first&.identifier}) end end diff --git a/app/models/message_template/competition_view.rb b/app/models/message_template/competition_review.rb similarity index 95% rename from app/models/message_template/competition_view.rb rename to app/models/message_template/competition_review.rb index d669d7fda..12bf5a883 100644 --- a/app/models/message_template/competition_view.rb +++ b/app/models/message_template/competition_review.rb @@ -24,7 +24,7 @@ # 点击通知跳转页面 # 点击此通知将跳转到代码审查大赛详情页: # http://117.50.100.12:8080/competitions/lgw7st/home -class MessageTemplate::CompetitionView < MessageTemplate +class MessageTemplate::CompetitionReview < MessageTemplate # MessageTemplate::FollowedTip.get_message_content(User.where(login: 'yystopf'), User.last) def self.get_message_content(receivers, competition) diff --git a/lib/tasks/competition_notice.rake b/lib/tasks/competition_notice.rake new file mode 100644 index 000000000..3de5b3eeb --- /dev/null +++ b/lib/tasks/competition_notice.rake @@ -0,0 +1,38 @@ +# 竞赛通知 + +namespace :competition_notice do + + desc "竞赛通知-进入提交作品状态" + task submit_work_begin: :environment do + competitions = Project.find_by_sql("select * from competitions where status=1 and DATE_FORMAT(enroll_end_time,'%Y-%m-%d %h:00:00') ='#{(Time.now - 1.day).strftime('%Y-%m-%d %H:00:00')}' ") + competitions.each do |c| + competition_teams = Project.find_by_sql("select * from competition_teams where competition_id=#{c.id} ") + competition_teams.each do |team| + SendTemplateMessageJob.perform_later('CompetitionBegin', team.user_id, c.id) + end + end + end + + desc "竞赛通知-截止提交作品时间前3小时" + task submit_work_end: :environment do + competitions = Project.find_by_sql("select * from competitions where status=1 and DATE_FORMAT(end_time,'%Y-%m-%d %h:00:00') ='#{(Time.now + 3.hours).strftime('%Y-%m-%d %H:00:00')}' ") + competitions.each do |c| + competition_teams = Project.find_by_sql("select * from competition_teams where competition_id=#{c.id} ") + competition_teams.each do |team| + SendTemplateMessageJob.perform_later('CompetitionReview', team.user_id, c.id) + end + end + end + + desc "竞赛通知-报名的竞赛进入成绩公示阶段" + task submit_work_result: :environment do + competitions = Project.find_by_sql("select * from competitions where status=1 and DATE_FORMAT(review_time,'%Y-%m-%d %h:00:00') ='#{(Time.now - 1.day).strftime('%Y-%m-%d %H:00:00')}' ") + competitions.each do |c| + competition_teams = Project.find_by_sql("select * from competition_teams where competition_id=#{c.id} ") + competition_teams.each do |team| + SendTemplateMessageJob.perform_later('CompetitionResult', team.user_id, c.id) + end + end + end + +end \ No newline at end of file From 4e3f9cc01927b87b674475aa0019bc0f70b65894 Mon Sep 17 00:00:00 2001 From: xiaoxiaoqiong Date: Mon, 21 Feb 2022 16:48:59 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=B0=83=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/message_template.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/message_template.rb b/app/models/message_template.rb index 25f9d06d8..f34200132 100644 --- a/app/models/message_template.rb +++ b/app/models/message_template.rb @@ -78,7 +78,7 @@ class MessageTemplate < ApplicationRecord # 竞赛通知 self.create(type: 'MessageTemplate::CompetitionBegin', sys_notice: '你报名的竞赛 {competition_name} 已进入比赛进行阶段,可在此期间提交作品', notification_url: '{to_url}') self.create(type: 'MessageTemplate::CompetitionResult', sys_notice: '你报名的竞赛 {competition_name} 已进入成绩公示阶段,可查看排行榜信息', notification_url: '{to_url}') - self.create(type: 'MessageTemplate::CompetitionView', sys_notice: '你报名的竞赛 {competition_name} 距作品提交结束日期仅剩3天,若尚未提交参赛作品,请尽快提交', notification_url: '{to_url}') + self.create(type: 'MessageTemplate::CompetitionReview', sys_notice: '你报名的竞赛 {competition_name} 距作品提交结束日期仅剩3天,若尚未提交参赛作品,请尽快提交', notification_url: '{to_url}') end def self.sys_notice From c6b79f82bc9a1cadb6636f4e033fb9e8fd0dd560 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 22 Feb 2022 10:03:51 +0800 Subject: [PATCH 12/12] fix: change password new version --- app/controllers/accounts_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 4244287b8..e40630c6b 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -192,7 +192,9 @@ class AccountsController < ApplicationController sync_params = { password: params[:password].to_s, - email: @user.mail + email: @user.mail, + login_name: @user.login, + source_id: 0 } interactor = Gitea::User::UpdateInteractor.call(@user.login, sync_params)