socialforge/config/initializers/send_mail.rb

28 lines
768 B
Ruby

#!/usr/bin/env ruby
require 'rubygems'
require 'rufus-scheduler'
#users = User.where("mail_notification = 'week' or mail_notification = 'day'")
scheduler = Rufus::Scheduler.new
scheduler.cron('0 0 * * 1') do
users = User.where("mail_notification = 'week'")
users.each do |user|
#Rails.logger.info "send mail to #{user.show_name}(#{user.mail}) at #{Time.now}"
Thread.start do
Mailer.send_for_user_activities(user, Date.today, 7).deliver
end
end
end
scheduler.cron('0 0 * * *') do
users = User.where("mail_notification = 'day'")
users.each do |user|
#Rails.logger.info "send mail to #{user.show_name}(#{user.mail}) at #{Time.now}"
Thread.start do
Mailer.send_for_user_activities(user, Date.today, 1).deliver
end
end
end