Sha256: cf0302adba46558f195e1e905d5f12489b6085ab199347885eaeecf17ea3569b
Contents?: true
Size: 938 Bytes
Versions: 1
Compression:
Stored size: 938 Bytes
Contents
# frozen_string_literal: true module Decidim module Msad module MailInterceptors # Prevents sending emails to the auto-generated email addresses. class GeneratedRecipientsInterceptor def self.delivering_email(message) return unless Decidim::Msad.auto_email_domain # Regexp to match the auto-generated emails regexp = /^msad-[a-z0-9]{32}@#{Decidim::Msad.auto_email_domain}$/ # Remove the auto-generated email from the message recipients message.to = message.to.reject { |email| email =~ regexp } if message.to message.cc = message.cc.reject { |email| email =~ regexp } if message.cc message.bcc = message.bcc.reject { |email| email =~ regexp } if message.bcc # Prevent delivery in case there are no recipients on the email message.perform_deliveries = false if message.to.empty? end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
decidim-msad-0.22.0 | lib/decidim/msad/mail_interceptors/generated_recipients_interceptor.rb |