diff --git a/app/controllers/birthdays_controller.rb b/app/controllers/birthdays_controller.rb index ada8769..4408dcc 100644 --- a/app/controllers/birthdays_controller.rb +++ b/app/controllers/birthdays_controller.rb @@ -12,10 +12,11 @@ class BirthdaysController < ApplicationController # crontab: # 30 3 * * * wget --post-data '' http://contact-o-rama.de/birthdays/do_mailing def do_mailing - birthdays = get_birthdays_next_7d - logger.debug "birthdays.nil? = " + birthdays.nil?.to_s + "......" + birthdays_2d = get_birthdays_next_2d + birthdays_7d = get_birthdays_next_7d + logger.debug "birthdays_2d.nil? = " + birthdays_2d.nil?.to_s + "......" unless birthdays.nil? - birthdays_by_email = group_birthdays_by_email(birthdays) + birthdays_by_email = group_birthdays_by_email(birthdays_7d) birthdays_by_email.each do |email, bdays| UserMailer.next_weeks_birthday_notification(email, bdays).deliver end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index bbb640c..f0dec74 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -7,6 +7,12 @@ class UserMailer < ActionMailer::Base mail(:to => email, :subject => "Contact-o-Rama: Geburtstage in den nächsten 7 Tagen.") end + def upcoming_birthdays_notification(email, birthdays_2days, birthdays_7days) + @birthday_contacts_2days = birthdays_2days + @birthday_contacts_2days = birthdays_7days + mail(:to => email, :subject => "Contact-o-Rama: anstehende Geburtstage") + end + # obsolete # def next_weeks_birthday_notification(birthdays) # logger.debug "----------------< we don't send no email, yet >----------------------" diff --git a/app/views/user_mailer/upcoming_birthdays_notification.html.erb b/app/views/user_mailer/upcoming_birthdays_notification.html.erb new file mode 100644 index 0000000..1e0c8ed --- /dev/null +++ b/app/views/user_mailer/upcoming_birthdays_notification.html.erb @@ -0,0 +1,32 @@ +<% unless (@birthday_contacts_2days.blank? && @birthday_contacts_7days.blank?) %> +
| + Contact-o-Rama: anstehende Geburtstage + + |
|---|