mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-22 12:45:46 +08:00
Merge branch 'develop' into standalone_develop
This commit is contained in:
51
app/models/message_template/custom_tip.rb
Normal file
51
app/models/message_template/custom_tip.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
# == 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)
|
||||
#
|
||||
|
||||
# 统一模板(
|
||||
|
||||
class MessageTemplate::CustomTip < MessageTemplate
|
||||
|
||||
# MessageTemplate::CustomTip.get_message_content(User.where(login: 'yystopf'), "hahah")
|
||||
def self.get_message_content(receivers, template, props={})
|
||||
return '', '', '' if receivers.blank? || template.blank?
|
||||
content = template.sys_notice
|
||||
notification_url = template.notification_url
|
||||
props.each do |k, v|
|
||||
content.gsub!("{#{k}}", v)
|
||||
notification_url.gsub!("{#{k}}", v)
|
||||
end
|
||||
return receivers_string(receivers), content, notification_url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::CustomTip.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
|
||||
def self.get_email_message_content(receiver, template, props={})
|
||||
return '', '', '' if receiver.blank? || template.blank?
|
||||
title = template.email_title
|
||||
content = template.email
|
||||
props.each do |k, v|
|
||||
title.gsub!("{#{k}}", v)
|
||||
content.gsub!("{#{k}}", v)
|
||||
end
|
||||
content.gsub!('{receiver}', receiver&.real_name)
|
||||
title.gsub!('{platform}', PLATFORM)
|
||||
content.gsub!('{platform}', PLATFORM)
|
||||
|
||||
return receiver&.mail, title, content
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::CustomTip.get_email_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user