Class: Decidim::Mpassid::MailInterceptors::GeneratedRecipientsInterceptor
- Inherits:
-
Object
- Object
- Decidim::Mpassid::MailInterceptors::GeneratedRecipientsInterceptor
- Defined in:
- lib/decidim/mpassid/mail_interceptors/generated_recipients_interceptor.rb
Overview
Prevents sending emails to the auto-generated email addresses.
Class Method Summary collapse
Class Method Details
.delivering_email(message) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/decidim/mpassid/mail_interceptors/generated_recipients_interceptor.rb', line 8 def self.delivering_email() return unless Decidim::Mpassid.auto_email_domain # Regexp to match the auto-generated emails regexp = /^mpassid-[a-z0-9]{32}@#{Decidim::Mpassid.auto_email_domain}$/ # Remove the auto-generated email from the message recipients .to = .to.reject { |email| email =~ regexp } if .to .cc = .cc.reject { |email| email =~ regexp } if .cc .bcc = .bcc.reject { |email| email =~ regexp } if .bcc # Prevent delivery in case there are no recipients on the email .perform_deliveries = false if .to.empty? end |