|
|
@ -17,8 +17,6 @@
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
|
|
class Mailer < ActionMailer::Base
|
|
|
|
class Mailer < ActionMailer::Base
|
|
|
|
require 'net/http'
|
|
|
|
|
|
|
|
require 'json'
|
|
|
|
|
|
|
|
layout 'mailer'
|
|
|
|
layout 'mailer'
|
|
|
|
helper :application
|
|
|
|
helper :application
|
|
|
|
helper :issues
|
|
|
|
helper :issues
|
|
|
@ -642,9 +640,6 @@ class Mailer < ActionMailer::Base
|
|
|
|
mail :to => recipients,
|
|
|
|
mail :to => recipients,
|
|
|
|
:subject => "[ #{l(:label_user_homework)} : #{homework_common.name} #{l(:label_memo_create_succ)}]",
|
|
|
|
:subject => "[ #{l(:label_user_homework)} : #{homework_common.name} #{l(:label_memo_create_succ)}]",
|
|
|
|
:filter => true
|
|
|
|
:filter => true
|
|
|
|
@homework_common.course.members.each do |member|
|
|
|
|
|
|
|
|
mail_wechat_message member.user_id, "3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", "您的课程有新作业了", @homework_common.course.name, @homework_common.name, @homework_common.end_time.to_s + " 23:59:59"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Builds a Mail::Message object used to email recipients of a news' project when a news item is added.
|
|
|
|
# Builds a Mail::Message object used to email recipients of a news' project when a news item is added.
|
|
|
@ -710,8 +705,6 @@ class Mailer < ActionMailer::Base
|
|
|
|
mail :to => recipients,
|
|
|
|
mail :to => recipients,
|
|
|
|
:subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}",
|
|
|
|
:subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}",
|
|
|
|
:filter => true
|
|
|
|
:filter => true
|
|
|
|
|
|
|
|
|
|
|
|
mail_wechat_message news.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的课程通知有新回复了", @author.try(:realname), format_time(comment.created_on), comment.comments.html_safe
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -736,13 +729,6 @@ class Mailer < ActionMailer::Base
|
|
|
|
:cc => cc,
|
|
|
|
:cc => cc,
|
|
|
|
:subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
|
|
|
|
:subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
|
|
|
|
:filter => true
|
|
|
|
:filter => true
|
|
|
|
if message.parent_id == nil
|
|
|
|
|
|
|
|
message.project.members.each do |member|
|
|
|
|
|
|
|
|
mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "项目讨论区有新帖子发布了", message.subject, @author.try(:realname), format_time(message.created_on)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
mail_wechat_message message.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), format_time(message.created_on), message.content.html_safe
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
elsif message.course
|
|
|
|
elsif message.course
|
|
|
|
redmine_headers 'Course' => message.course.id,
|
|
|
|
redmine_headers 'Course' => message.course.id,
|
|
|
|
'Topic-Id' => (message.parent_id || message.id)
|
|
|
|
'Topic-Id' => (message.parent_id || message.id)
|
|
|
@ -758,13 +744,6 @@ class Mailer < ActionMailer::Base
|
|
|
|
:cc => cc,
|
|
|
|
:cc => cc,
|
|
|
|
:subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
|
|
|
|
:subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
|
|
|
|
:filter => true
|
|
|
|
:filter => true
|
|
|
|
if message.parent_id == nil
|
|
|
|
|
|
|
|
message.course.members.each do |member|
|
|
|
|
|
|
|
|
mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "课程问答区有新帖子发布了", message.subject, @author.try(:realname), format_time(message.created_on)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
mail_wechat_message message.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), format_time(message.created_on), message.content.html_safe
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -1119,48 +1098,4 @@ class Mailer < ActionMailer::Base
|
|
|
|
1.upto(len) { |i| newpass << chars[rand(chars.size-1)] }
|
|
|
|
1.upto(len) { |i| newpass << chars[rand(chars.size-1)] }
|
|
|
|
return newpass
|
|
|
|
return newpass
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#微信模板消息
|
|
|
|
|
|
|
|
def mail_wechat_message user_id, template_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站"
|
|
|
|
|
|
|
|
uw = UserWechat.where(user_id: user_id).first
|
|
|
|
|
|
|
|
logger.info "mail_wechat_message #{user_id} #{uw}"
|
|
|
|
|
|
|
|
unless uw.nil?
|
|
|
|
|
|
|
|
data = {
|
|
|
|
|
|
|
|
touser:uw.openid,
|
|
|
|
|
|
|
|
template_id:template_id,
|
|
|
|
|
|
|
|
url:"http://www.trustie.net/",
|
|
|
|
|
|
|
|
topcolor:"#FF0000",
|
|
|
|
|
|
|
|
data:{
|
|
|
|
|
|
|
|
first: {
|
|
|
|
|
|
|
|
value:first,
|
|
|
|
|
|
|
|
color:"#173177"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
keyword1:{
|
|
|
|
|
|
|
|
value:key1,
|
|
|
|
|
|
|
|
color:"#173177"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
keyword2:{
|
|
|
|
|
|
|
|
value:key2,
|
|
|
|
|
|
|
|
color:"#173177"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
keyword3:{
|
|
|
|
|
|
|
|
value:key3,
|
|
|
|
|
|
|
|
color:"#173177"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
remark:{
|
|
|
|
|
|
|
|
value:remark,
|
|
|
|
|
|
|
|
color:"#173177"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.info "start send template message: #{data}"
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
|
|
|
logger.error "[mailer] ===> #{e}"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
logger.info "send over. #{req}"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|