From f2e2563d452a604671933118c57769e37a5137bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Sun, 1 Dec 2024 12:41:30 +0800 Subject: [PATCH] Add email_sent callback function for newer orbit kernel. --- app/models/paper_criteria.rb | 7 +++++++ lib/tasks/e_paper_tasks.rake | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/models/paper_criteria.rb b/app/models/paper_criteria.rb index 8143c63..9a82091 100755 --- a/app/models/paper_criteria.rb +++ b/app/models/paper_criteria.rb @@ -43,4 +43,11 @@ class PaperCriteria _email_sentdate end + def email_sent(mails, flag) + unless flag + self.send_failed_emails += mails + self.send_failed_emails.uniq! + self.save + end + end end diff --git a/lib/tasks/e_paper_tasks.rake b/lib/tasks/e_paper_tasks.rake index f450c88..f812f4e 100755 --- a/lib/tasks/e_paper_tasks.rake +++ b/lib/tasks/e_paper_tasks.rake @@ -49,7 +49,7 @@ namespace :epaper do emails_valid.each_slice(mail_limit).each do |slice_emails| invalid_mails = epaper_verify_email(from_addr,slice_emails,tls) deliver_emails = slice_emails - invalid_mails - email = Email.new(:mail_subject => paper.sending_title, :mail_lang => args[:locale], :template => "admin/e_paper_criterias/emailer", :template_data => {"paper_id" => paper.id, "page" => "http://" + domain + page, "siteurl" => "http://" + domain, "papers_data" => papers_data }, :mail_to => deliver_emails, :module_app_key=>'e_paper', :mail_sentdate=> email_sentdate) + email = Email.new(:mail_subject => paper.sending_title, :mail_lang => args[:locale], :template => "admin/e_paper_criterias/emailer", :template_data => {"paper_id" => paper.id, "page" => "http://" + domain + page, "siteurl" => "http://" + domain, "papers_data" => papers_data, "model_class" => "PaperCriteria", "model_id" => paper.id }, :mail_to => deliver_emails, :module_app_key=>'e_paper', :mail_sentdate=> email_sentdate) begin email.save if email_sentdate @@ -65,7 +65,7 @@ namespace :epaper do error_flag = 0 begin invalid_mails.each do |invalid_mail| - email = Email.create(:mail_subject => paper.sending_title, :mail_lang => args[:locale], :template => "admin/e_paper_criterias/emailer", :template_data => {"paper_id" => paper.id, "page" => "http://" + domain + page, "siteurl" => "http://" + domain, "papers_data" => papers_data }, :mail_to => invalid_mail, :module_app_key=>'e_paper', :mail_sentdate=> email_sentdate) + email = Email.create(:mail_subject => paper.sending_title, :mail_lang => args[:locale], :template => "admin/e_paper_criterias/emailer", :template_data => {"paper_id" => paper.id, "page" => "http://" + domain + page, "siteurl" => "http://" + domain, "papers_data" => papers_data, "model_class" => "PaperCriteria", "model_id" => paper.id }, :mail_to => invalid_mail, :module_app_key=>'e_paper', :mail_sentdate=> email_sentdate) end rescue => e puts [e,e.backtrace]