forked from Gitlink/forgeplus
新增:通过审核发送消息
This commit is contained in:
parent
07324662e5
commit
9bbb66f890
|
|
@ -77,6 +77,7 @@ class ApplySignaturesController < ApplicationController
|
|||
return normal_status(-1, "已经是该状态了") if @apply_signature.status == params[:status]
|
||||
@apply_signature.update_attributes!(apply_signature_params)
|
||||
if @apply_signature.status == "passed"
|
||||
SendTemplateMessageJob.perform_later('ApplySignaturePassed', @apply_signature.user_id, @apply_signature.id)
|
||||
Projects::AddMemberInteractor.call(@apply_signature.project.owner, @apply_signature.project, @apply_signature.user, "read", true)
|
||||
else
|
||||
Projects::DeleteMemberInteractor.call(@apply_signature.project.owner, @apply_signature.project, @apply_signature.user)
|
||||
|
|
|
|||
|
|
@ -376,6 +376,14 @@ class SendTemplateMessageJob < ApplicationJob
|
|||
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})
|
||||
when 'ApplySignaturePassed'
|
||||
user_id, apply_signature_id = args[0], args[1]
|
||||
user = User.find_by_id(user_id)
|
||||
apply_signature = ApplySignature.find_by_id apply_signature_id
|
||||
return unless user.present? && apply_signature.present?
|
||||
receivers = User.where(id: user_id)
|
||||
receivers_string, content, notification_url = MessageTemplate::ApplySignaturePassed.get_message_content(receivers, apply_signature)
|
||||
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {user_id: user_id, apply_signature_id: apply_signature_id})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -80,6 +80,8 @@ class MessageTemplate < ApplicationRecord
|
|||
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}')
|
||||
# 用户提交审核通知
|
||||
self.create(type: 'MessageTemplate::ApplySignaturePassed', sys_notice: '您提交的 {nickname}/{repository} 仓库访问申请已审核通过,可正常访问受限仓库。{ifcdkey}软件激活码:{cdkey} {endcdkey}', notification_url: '{baseurl}/{owner}/{identifier}')
|
||||
end
|
||||
|
||||
def self.sys_notice
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
class MessageTemplate::ApplySignaturePassed < MessageTemplate
|
||||
|
||||
# MessageTemplate::ApplySignaturePassed.get_message_content(User.where(phone: 15386415121), ApplySignature.last)
|
||||
def self.get_message_content(receivers, apply_signature)
|
||||
return '', '', '' if receivers.blank?
|
||||
project = apply_signature&.project
|
||||
owner = project&.owner
|
||||
content = sys_notice.gsub('{nickname}', owner&.real_name).gsub('{repository}', project&.name)
|
||||
url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier)
|
||||
if apply_signature.cdkey.present?
|
||||
content.sub!('{ifcdkey}', '')
|
||||
content.sub!('{endcdkey}', '')
|
||||
content.gsub!('{cdkey}', apply_signature.cdkey)
|
||||
else
|
||||
content.gsub!(/({ifcdkey})(.*)({endcdkey})/, '')
|
||||
end
|
||||
return receivers_string(receivers), content, url
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue