forked from Gitlink/forgeplus
merge from develop
This commit is contained in:
commit
f2f2ce8252
|
@ -192,7 +192,9 @@ class AccountsController < ApplicationController
|
|||
|
||||
sync_params = {
|
||||
password: params[:password].to_s,
|
||||
email: @user.mail
|
||||
email: @user.mail,
|
||||
login_name: @user.name,
|
||||
source_id: 0
|
||||
}
|
||||
|
||||
interactor = Gitea::User::UpdateInteractor.call(@user.login, sync_params)
|
||||
|
|
|
@ -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"] == "CompetitionReview"
|
||||
competition_id = params[:competition_id]
|
||||
SendTemplateMessageJob.perform_later('CompetitionReview', user_id, competition_id)
|
||||
else
|
||||
tip_exception("#{params["source"]}未配置")
|
||||
end
|
||||
render_ok
|
||||
end
|
||||
end
|
|
@ -326,6 +326,30 @@ 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::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
|
||||
end
|
|
@ -74,6 +74,11 @@ class MessageTemplate < ApplicationRecord
|
|||
self.create(type: 'MessageTemplate::TeamJoined', sys_notice: '你已被拉入组织 <b>{organization}</b> 的 <b>{team}</b> 团队,拥有<b>{role}</b>权限', 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: '你已被移出组织 <b>{organization}</b> 的 <b>{team}</b> 团队', email: email_html, email_title: "#{PLATFORM}: 在 {organization} 组织你的账号有权限变更", notification_url: '{baseurl}/{login}')
|
||||
|
||||
# 竞赛通知
|
||||
self.create(type: 'MessageTemplate::CompetitionBegin', sys_notice: '你报名的竞赛 <b>{competition_name}</b> 已进入比赛进行阶段,可在此期间提交作品', notification_url: '{to_url}')
|
||||
self.create(type: 'MessageTemplate::CompetitionResult', sys_notice: '你报名的竞赛 <b>{competition_name}</b> 已进入成绩公示阶段,可查看排行榜信息', notification_url: '{to_url}')
|
||||
self.create(type: 'MessageTemplate::CompetitionReview', sys_notice: '你报名的竞赛 <b>{competition_name}</b> 距作品提交结束日期仅剩3天,若尚未提交参赛作品,请尽快提交', notification_url: '{to_url}')
|
||||
end
|
||||
|
||||
def self.sys_notice
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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::CompetitionReview < 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
|
|
@ -9,7 +9,6 @@ Rails.application.routes.draw do
|
|||
# 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'
|
||||
|
@ -25,7 +24,6 @@ Rails.application.routes.draw do
|
|||
resources :edu_settings
|
||||
|
||||
scope '/api' do
|
||||
resources :topics, only: [:index]
|
||||
namespace :ci do
|
||||
resources :languages, only: [:index, :show] do
|
||||
collection do
|
||||
|
@ -147,16 +145,6 @@ Rails.application.routes.draw do
|
|||
get :get_children_journals
|
||||
end
|
||||
end
|
||||
|
||||
resources :claims, only: [:index] do
|
||||
collection do
|
||||
post :create
|
||||
delete :destroy
|
||||
get :index
|
||||
put :update
|
||||
end
|
||||
end
|
||||
|
||||
resources :issue_times, only: [:create] do
|
||||
collection do
|
||||
post :end_work
|
||||
|
@ -385,6 +373,7 @@ Rails.application.routes.draw do
|
|||
resource :bind_user, only: [:create]
|
||||
|
||||
resources :hot_keywords, only: [:index]
|
||||
resources :notices, only: [:create]
|
||||
|
||||
namespace :weapps do
|
||||
resource :home, only: [:show]
|
||||
|
@ -683,16 +672,6 @@ Rails.application.routes.draw do
|
|||
namespace :admins do
|
||||
mount Sidekiq::Web => '/sidekiq'
|
||||
get '/', to: 'dashboards#index'
|
||||
namespace :topic do
|
||||
resources :activity_forums
|
||||
resources :banners
|
||||
resources :cards
|
||||
resources :cooperators
|
||||
resources :excellent_projects
|
||||
resources :experience_forums
|
||||
resources :pinned_forums
|
||||
end
|
||||
|
||||
resources :project_statistics, only: [:index] do
|
||||
collection do
|
||||
get :visits_static
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue