邮件发送至发送邮件重要信息, 去掉掉按天发送功能

This commit is contained in:
huang 2016-11-30 10:58:13 +08:00
parent dbc8c5811a
commit 890b0e80fd
7 changed files with 262 additions and 262 deletions

View File

@ -40,7 +40,7 @@ class Comment < ActiveRecord::Base
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
validates_presence_of :commented, :author, :comments
safe_attributes 'comments','parent_id','reply_id','comments_count'
after_create :send_mail, :act_as_system_message, :act_as_student_score
after_create :act_as_system_message, :act_as_student_score #:send_mail,
after_destroy :down_course_score
def act_as_system_message
@ -55,11 +55,11 @@ class Comment < ActiveRecord::Base
# end
end
else # 项目相关
if self.author_id != self.commented.author_id
self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false)
#content = strip_html self.comments.html_safe, 200
#ws.comment_template self.commented.author_id, "blog_comment", self.id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
end
# if self.author_id != self.commented.author_id
# self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false)
# #content = strip_html self.comments.html_safe, 200
# #ws.comment_template self.commented.author_id, "blog_comment", self.id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
# end
end
end

View File

@ -1,7 +1,7 @@
# Added by young
class JournalsForMessageObserver < ActiveRecord::Observer
def after_create(journals_for_message)
Mailer.run.journals_for_message_add(User.current, journals_for_message)
# Mailer.run.journals_for_message_add(User.current, journals_for_message)
end
end

View File

@ -109,40 +109,40 @@ class Mailer < ActionMailer::Base
# 邀请未注册用户加入项目
# 功能: 在加入项目的同时自动注册用户
def send_invite_in_project(email, project, invitor, first_name, last_name, gender)
@email = email
@subject = "#{invitor.name} #{l(:label_invite_project)} #{project.name} "
@password = newpass(6)
login = email
login = login.sub(/%40/,'@')
us = UsersService.new
# 自动激活用户
user = us.register_auto(login, email, @password, first_name, last_name, gender)
InviteList.create(:user_id => user.id, :project_id => project.id, :mail =>email)
User.current = user unless User.current.nil?
@user = user
@token = Token.get_token_from_user(user, 'autologin')
@project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :mail => true, :token => @token.value)
mail :to => email, :subject => @subject
# @email = email
# @subject = "#{invitor.name} #{l(:label_invite_project)} #{project.name} "
# @password = newpass(6)
#
# login = email
# login = login.sub(/%40/,'@')
# us = UsersService.new
# # 自动激活用户
# user = us.register_auto(login, email, @password, first_name, last_name, gender)
# InviteList.create(:user_id => user.id, :project_id => project.id, :mail =>email)
# User.current = user unless User.current.nil?
# @user = user
# @token = Token.get_token_from_user(user, 'autologin')
# @project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :mail => true, :token => @token.value)
# mail :to => email, :subject => @subject
end
# 邀请已注册的用户加入项目
def request_member_to_project(email, project, invitor)
@subject = "#{invitor.name} #{l(:label_invite_project)}: #{project.name} "
user = User.find_by_mail(email.to_s)
@invitor_name = "#{invitor.name}"
@project_name = "#{project.name}"
@user = user
@project = project
if InviteList.where("project_id= ? and user_id =? and mail =?", project.id, @user.id, email).first.nil?
InviteList.create(:user_id => user.id, :project_id => project.id, :mail => email)
end
@token = Token.get_token_from_user(user, 'autologin')
@project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value)
# 发送消息邀请
send_message_request_member(user,project)
# @subject = "#{invitor.name} #{l(:label_invite_project)}: #{project.name} "
# user = User.find_by_mail(email.to_s)
# @invitor_name = "#{invitor.name}"
# @project_name = "#{project.name}"
# @user = user
# @project = project
# if InviteList.where("project_id= ? and user_id =? and mail =?", project.id, @user.id, email).first.nil?
# InviteList.create(:user_id => user.id, :project_id => project.id, :mail => email)
# end
mail :to => email, :subject => @subject
# @token = Token.get_token_from_user(user, 'autologin')
# @project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value)
# # 发送消息邀请
# send_message_request_member(user,project)
# # end
# mail :to => email, :subject => @subject
end
# 邀请信息消息 注forge_message_id 为邀请人ID(特殊情况)
@ -293,23 +293,23 @@ class Mailer < ActionMailer::Base
# 公共讨论区发帖、回帖添加邮件发送信息
def forum_message_added(memo)
@memo = memo
redmine_headers 'Memo' => memo.id
@forum = memo.forum
@author = memo.author
@forum_url = url_for(:controller => 'forums', :action => 'show', :id => @forum.id)
@issue_author_url = url_for(user_activities_url(@author))
recipients ||= []
#将帖子创建者邮箱地址加入数组
recipients << @forum.creator.mail
#回复人邮箱地址加入数组
recipients << @author.mail
# cc = wiki_content.page.wiki.watcher_recipients - recipients
@memo_url = url_for(forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id)))
mail :to => recipients,
:subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]",
:filter => true
# @memo = memo
# redmine_headers 'Memo' => memo.id
# @forum = memo.forum
# @author = memo.author
# @forum_url = url_for(:controller => 'forums', :action => 'show', :id => @forum.id)
# @issue_author_url = url_for(user_activities_url(@author))
# recipients ||= []
# #将帖子创建者邮箱地址加入数组
# recipients << @forum.creator.mail
# #回复人邮箱地址加入数组
# recipients << @author.mail
# # cc = wiki_content.page.wiki.watcher_recipients - recipients
#
# @memo_url = url_for(forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id)))
# mail :to => recipients,
# :subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]",
# :filter => true
end
# Builds a Mail::Message object used to email recipients of the added journals for message.
@ -318,64 +318,64 @@ class Mailer < ActionMailer::Base
# 直接留言后 reply_id,m_parent_id 为空相对应的at_user取值为nil
def journals_for_message_add(user, journals_for_message)
@user = journals_for_message.user # 留言人
@mail = journals_for_message.jour if journals_for_message.at_user.nil? # 留言
@mail = journals_for_message.at_user if journals_for_message.at_user
@message = journals_for_message.notes
@title = "#@user #{t(:label_leave_your_message, :locale => 'zh')}"
@issue_author_url = url_for(user_activities_url(@user))
@url = case journals_for_message.jour.class.to_s.to_sym # 判断留言的对象所属类型
# when :Bid
# course_for_bid_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
when :Project
return -1 if journals_for_message.jour.project_type == Project::ProjectType_project
project_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
when :Course
course_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
when :Contest
show_contest_contest_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
when :User
user_newfeedback_user_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
else
Rails.logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}"
return -1
end
# 验证用户的收取邮件的方式
recipients ||= []
recipients1 ||= []
recipients1 = @mail.mail
recipients = journals_for_message.jour.author.mail
# modify by nwb
#如果是直接留言并且留言对象是课程
if !journals_for_message.at_user && journals_for_message.jour.class.to_s.to_sym == :Course
course = journals_for_message.jour
@author = journals_for_message.user
#课程的教师
@members = course_all_member journals_for_message.jour
#收件人邮箱
@recipients ||= []
@members.each do |teacher|
@recipients << teacher.user.mail
end
mail :to => @recipients,
:subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} ",
:filter => true
# elsif journals_for_message.jour.class.to_s.to_sym == :Bid
# @user = journals_for_message.user # 留言人
# @mail = journals_for_message.jour if journals_for_message.at_user.nil? # 留言
# @mail = journals_for_message.at_user if journals_for_message.at_user
# @message = journals_for_message.notes
# @title = "#@user #{t(:label_leave_your_message, :locale => 'zh')}"
# @issue_author_url = url_for(user_activities_url(@user))
# @url = case journals_for_message.jour.class.to_s.to_sym # 判断留言的对象所属类型
# # when :Bid
# # course_for_bid_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
# when :Project
# return -1 if journals_for_message.jour.project_type == Project::ProjectType_project
# project_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
# when :Course
# course_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
# when :Contest
# show_contest_contest_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
# when :User
# user_newfeedback_user_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
# else
# Rails.logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}"
# return -1
# end
#
# # 验证用户的收取邮件的方式
# recipients ||= []
# recipients1 ||= []
# recipients1 = @mail.mail
# recipients = journals_for_message.jour.author.mail
#
# # modify by nwb
# #如果是直接留言并且留言对象是课程
# if !journals_for_message.at_user && journals_for_message.jour.class.to_s.to_sym == :Course
# course = journals_for_message.jour
# @author = journals_for_message.user
# #课程的教师
# @members = course_all_member journals_for_message.jour
# #收件人邮箱
# @recipients ||= []
# @members.each do |teacher|
# @recipients << teacher.user.mail
# end
# mail :to => @recipients,
# :subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} ",
# :filter => true
# # elsif journals_for_message.jour.class.to_s.to_sym == :Bid
# # if !journals_for_message.jour.author.notify_about? journals_for_message
# # return -1
# # end
# #
# # mail :to => recipients, :subject => @title,:filter => true
# elsif journals_for_message.jour.class.to_s.to_sym == :Contest
# if !journals_for_message.jour.author.notify_about? journals_for_message
# return -1
# end
#
# mail :to => recipients, :subject => @title,:filter => true
elsif journals_for_message.jour.class.to_s.to_sym == :Contest
if !journals_for_message.jour.author.notify_about? journals_for_message
return -1
end
mail :to => recipients, :subject => @title,:filter => true
else
mail :to => recipients1, :subject => @title,:filter => true
end
# else
# mail :to => recipients1, :subject => @title,:filter => true
# end
end
@ -485,16 +485,16 @@ class Mailer < ActionMailer::Base
# 用户申请加入项目邮件通知
def applied_project(applied)
@project =applied.project
redmine_headers 'Project' => @project,
'User' => applied.user
@user = applied.user
recipients = @project.manager_recipients
s = l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name)
@token = Token.get_token_from_user(@user, 'autologin')
@applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members')
mail :to => recipients,
:subject => s
# @project =applied.project
# redmine_headers 'Project' => @project,
# 'User' => applied.user
# @user = applied.user
# recipients = @project.manager_recipients
# s = l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name)
# @token = Token.get_token_from_user(@user, 'autologin')
# @applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members')
# mail :to => recipients,
# :subject => s
end
def reminder(user, issues, days)
@ -555,14 +555,14 @@ class Mailer < ActionMailer::Base
# document_added(document) => Mail::Message object
# Mailer.document_added(document).deliver => sends an email to the document's project recipients
def document_added(document)
redmine_headers 'Project' => document.project.identifier
@author = User.current
@document = document
@issue_author_url = url_for(user_activities_url(@author))
@document_url = url_for(:controller => 'documents', :action => 'show', :id => document)
mail :to => document.recipients,
:subject => "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}",
:filter => true
# redmine_headers 'Project' => document.project.identifier
# @author = User.current
# @document = document
# @issue_author_url = url_for(user_activities_url(@author))
# @document_url = url_for(:controller => 'documents', :action => 'show', :id => document)
# mail :to => document.recipients,
# :subject => "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}",
# :filter => true
end
# Builds a Mail::Message object used to email recipients of a project when an attachements are added.
@ -571,54 +571,54 @@ class Mailer < ActionMailer::Base
# attachments_added(attachments) => Mail::Message object
# Mailer.attachments_added(attachments).deliver => sends an email to the project's recipients
def attachments_added(attachments)
container = attachments.first.container
added_to = ''
added_to_url = ''
@author = attachments.first.author
@issue_author_url = url_for(user_activities_url(@author))
case container.class.name
when 'Project'
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
added_to = "#{l(:label_project)}: #{container}"
recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
when 'Course'
added_to_url = url_for(:controller => 'files', :action => 'index', :course_id => container)
added_to = "#{l(:label_course)}: #{container.name}"
recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
when 'Version'
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
added_to = "#{l(:label_version)}: #{container.name}"
recipients = container.project.notified_users.select { |user| user.allowed_to?(:view_files, container.project) }.collect { |u| u.mail }
when 'Document'
added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id)
added_to = "#{l(:label_document)}: #{container.title}"
recipients = container.recipients
end
if container.class.name == 'Course'
redmine_headers 'Course' => container.id
@attachments = attachments
@added_to = added_to
@added_to_url = added_to_url
mail :to => recipients,
:subject => "[#{container.name}] #{l(:label_attachment_new)}",
:filter => true
elsif container.class.name == 'Project'
redmine_headers 'Project' => container.id
@attachments = attachments
@added_to = added_to
@added_to_url = added_to_url
mail :to => recipients,
:subject => "[#{container.name}] #{l(:label_attachment_new)}",
:filter => true
else
redmine_headers 'Project' => container.project.identifier
@attachments = attachments
@added_to = added_to
@added_to_url = added_to_url
mail :to => recipients,
:subject => "[#{container.project.name}] #{l(:label_attachment_new)}",
:filter => true
end
# container = attachments.first.container
# added_to = ''
# added_to_url = ''
# @author = attachments.first.author
# @issue_author_url = url_for(user_activities_url(@author))
# case container.class.name
# when 'Project'
# added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
# added_to = "#{l(:label_project)}: #{container}"
# recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
# when 'Course'
# added_to_url = url_for(:controller => 'files', :action => 'index', :course_id => container)
# added_to = "#{l(:label_course)}: #{container.name}"
# recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
# when 'Version'
# added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
# added_to = "#{l(:label_version)}: #{container.name}"
# recipients = container.project.notified_users.select { |user| user.allowed_to?(:view_files, container.project) }.collect { |u| u.mail }
# when 'Document'
# added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id)
# added_to = "#{l(:label_document)}: #{container.title}"
# recipients = container.recipients
# end
# if container.class.name == 'Course'
# redmine_headers 'Course' => container.id
# @attachments = attachments
# @added_to = added_to
# @added_to_url = added_to_url
# mail :to => recipients,
# :subject => "[#{container.name}] #{l(:label_attachment_new)}",
# :filter => true
# elsif container.class.name == 'Project'
# redmine_headers 'Project' => container.id
# @attachments = attachments
# @added_to = added_to
# @added_to_url = added_to_url
# mail :to => recipients,
# :subject => "[#{container.name}] #{l(:label_attachment_new)}",
# :filter => true
# else
# redmine_headers 'Project' => container.project.identifier
# @attachments = attachments
# @added_to = added_to
# @added_to_url = added_to_url
# mail :to => recipients,
# :subject => "[#{container.project.name}] #{l(:label_attachment_new)}",
# :filter => true
# end
end
# Builds a Mail::Message object used to email recipients of a course when an homework are posted.
@ -650,15 +650,15 @@ class Mailer < ActionMailer::Base
def news_added(news)
if news.project
redmine_headers 'Project' => news.project.identifier
@author = news.author
@issue_author_url = url_for(user_activities_url(@author))
message_id news
@news = news
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
mail :to => news.recipients,
:subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}",
:filter => true
# redmine_headers 'Project' => news.project.identifier
# @author = news.author
# @issue_author_url = url_for(user_activities_url(@author))
# message_id news
# @news = news
# @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
# mail :to => news.recipients,
# :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}",
# :filter => true
elsif news.course
redmine_headers 'Course' => news.course.id
@author = news.author
@ -681,17 +681,17 @@ class Mailer < ActionMailer::Base
def news_comment_added(comment)
news = comment.commented
if news.project
redmine_headers 'Project' => news.project.identifier
@author = comment.author
@issue_author_url = url_for(user_activities_url(@author))
message_id comment
@news = news
@comment = comment
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
mail :to => news.recipients,
:cc => news.watcher_recipients,
:subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}",
:filter => true
# redmine_headers 'Project' => news.project.identifier
# @author = comment.author
# @issue_author_url = url_for(user_activities_url(@author))
# message_id comment
# @news = news
# @comment = comment
# @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
# mail :to => news.recipients,
# :cc => news.watcher_recipients,
# :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}",
# :filter => true
elsif news.course
redmine_headers 'Course' => news.course.id
@author = comment.author
@ -714,37 +714,37 @@ class Mailer < ActionMailer::Base
# message_posted(message) => Mail::Message object
# Mailer.message_posted(message).deliver => sends an email to the recipients
def message_posted(message)
if message.project
redmine_headers 'Project' => message.project.identifier,
'Topic-Id' => (message.parent_id || message.id)
@author = message.author
@issue_author_url = url_for(user_activities_url(@author))
message_id message
references message.parent unless message.parent.nil?
recipients = message.recipients
cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients)
@message = message
@message_url = url_for(message.event_url)
mail :to => recipients,
:cc => cc,
:subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
:filter => true
elsif message.course
redmine_headers 'Course' => message.course.id,
'Topic-Id' => (message.parent_id || message.id)
@author = message.author
@issue_author_url = url_for(user_activities_url(@author))
message_id message
references message.parent unless message.parent.nil?
recipients = message.course.notified_users.select { |user| user.allowed_to?(:view_files, message.course) }.collect { |u| u.mail }
cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients)
@message = message
@message_url = url_for(message.event_url)
mail :to => recipients,
:cc => cc,
:subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
:filter => true
end
# if message.project
# redmine_headers 'Project' => message.project.identifier,
# 'Topic-Id' => (message.parent_id || message.id)
# @author = message.author
# @issue_author_url = url_for(user_activities_url(@author))
# message_id message
# references message.parent unless message.parent.nil?
# recipients = message.recipients
# cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients)
# @message = message
# @message_url = url_for(message.event_url)
# mail :to => recipients,
# :cc => cc,
# :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
# :filter => true
# elsif message.course
# redmine_headers 'Course' => message.course.id,
# 'Topic-Id' => (message.parent_id || message.id)
# @author = message.author
# @issue_author_url = url_for(user_activities_url(@author))
# message_id message
# references message.parent unless message.parent.nil?
# recipients = message.course.notified_users.select { |user| user.allowed_to?(:view_files, message.course) }.collect { |u| u.mail }
# cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients)
# @message = message
# @message_url = url_for(message.event_url)
# mail :to => recipients,
# :cc => cc,
# :subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
# :filter => true
# end
end
# Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was added.
@ -753,20 +753,20 @@ class Mailer < ActionMailer::Base
# wiki_content_added(wiki_content) => Mail::Message object
# Mailer.wiki_content_added(wiki_content).deliver => sends an email to the project's recipients
def wiki_content_added(wiki_content)
redmine_headers 'Project' => wiki_content.project.identifier,
'Wiki-Page-Id' => wiki_content.page.id
@author = wiki_content.author
message_id wiki_content
recipients = wiki_content.recipients
cc = wiki_content.page.wiki.watcher_recipients - recipients
@wiki_content = wiki_content
@wiki_content_url = url_for(:controller => 'wiki', :action => 'show',
:project_id => wiki_content.project,
:id => wiki_content.page.title)
mail :to => recipients,
:cc => cc,
:subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}",
:filter => true
# redmine_headers 'Project' => wiki_content.project.identifier,
# 'Wiki-Page-Id' => wiki_content.page.id
# @author = wiki_content.author
# message_id wiki_content
# recipients = wiki_content.recipients
# cc = wiki_content.page.wiki.watcher_recipients - recipients
# @wiki_content = wiki_content
# @wiki_content_url = url_for(:controller => 'wiki', :action => 'show',
# :project_id => wiki_content.project,
# :id => wiki_content.page.title)
# mail :to => recipients,
# :cc => cc,
# :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}",
# :filter => true
end
# Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was updated.
@ -775,23 +775,23 @@ class Mailer < ActionMailer::Base
# wiki_content_updated(wiki_content) => Mail::Message object
# Mailer.wiki_content_updated(wiki_content).deliver => sends an email to the project's recipients
def wiki_content_updated(wiki_content)
redmine_headers 'Project' => wiki_content.project.identifier,
'Wiki-Page-Id' => wiki_content.page.id
@author = wiki_content.author
message_id wiki_content
recipients = wiki_content.recipients
cc = wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients
@wiki_content = wiki_content
@wiki_content_url = url_for(:controller => 'wiki', :action => 'show',
:project_id => wiki_content.project,
:id => wiki_content.page.title)
@wiki_diff_url = url_for(:controller => 'wiki', :action => 'diff',
:project_id => wiki_content.project, :id => wiki_content.page.title,
:version => wiki_content.version)
mail :to => recipients,
:cc => cc,
:subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}",
:filter => true
# redmine_headers 'Project' => wiki_content.project.identifier,
# 'Wiki-Page-Id' => wiki_content.page.id
# @author = wiki_content.author
# message_id wiki_content
# recipients = wiki_content.recipients
# cc = wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients
# @wiki_content = wiki_content
# @wiki_content_url = url_for(:controller => 'wiki', :action => 'show',
# :project_id => wiki_content.project,
# :id => wiki_content.page.title)
# @wiki_diff_url = url_for(:controller => 'wiki', :action => 'diff',
# :project_id => wiki_content.project, :id => wiki_content.page.title,
# :version => wiki_content.version)
# mail :to => recipients,
# :cc => cc,
# :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}",
# :filter => true
end
# Builds a Mail::Message object used to email the specified user their account information.

View File

@ -81,7 +81,7 @@ class Memo < ActiveRecord::Base
"parent_id",
"replies_count"
after_create :add_author_as_watcher, :reset_counters!, :send_mail, :send_message,:create_memo_ealasticsearch_index
after_create :add_author_as_watcher, :reset_counters!, :send_message,:create_memo_ealasticsearch_index
after_update :update_memo_ealasticsearch_index
after_destroy :reset_counters!,:delete_kindeditor_assets,:delete_memo_ealasticsearch_index#,:down_user_score -- 公共区发帖暂不计入得分,
# after_create :send_notification

View File

@ -65,7 +65,7 @@ class News < ActiveRecord::Base
:author_key => :author_id
acts_as_watchable
after_create :act_as_forge_activity, :act_as_course_activity, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score, :act_as_system_message,:delay_news_wechat_send,:delay_news_send
after_create :act_as_course_activity, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score,:delay_news_wechat_send, :delay_news_send
after_update :update_activity
after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score

View File

@ -82,7 +82,7 @@ class User < Principal
#每日一报、一事一报、不报
MAIL_NOTIFICATION_OPTIONS = [
#['week', :label_user_mail_option_week],
['day', :label_user_mail_option_day],
# ['day', :label_user_mail_option_day],
['all', :label_user_mail_option_all],
['none', :label_user_mail_option_none]
]

View File

@ -197,10 +197,10 @@ END_DESC
desc "send a email for day"
task :day => :environment do
users = User.where(mail_notification: 'day')
users.each do |user|
Mailer.run.send_for_user_activities(user, Date.today, 1)
end
# users = User.where(mail_notification: 'day')
# users.each do |user|
# Mailer.run.send_for_user_activities(user, Date.today, 1)
# end
end
end
end