Loading CHANGELOG.md +2 −1 Original line number Diff line number Diff line Loading @@ -5,8 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased changes - Issue #3314414: Added tests for 'reroute email' functionality. - #3314414: Added tests for 'reroute email' functionality. - #3318273: Make sure tests run on drupal.org infrastructure for the Domino module. - #3323954: Fixed issue with not working fallback for emails rerouting feature. ## [3.2.3] - Fixed bug with installing Reroute Email module on hook_update(). Loading domino.module +15 −12 Original line number Diff line number Diff line Loading @@ -40,12 +40,15 @@ function domino_cache_flush() { */ function domino_mail_alter(&$message) { $config = \Drupal::config('domino.settings'); if ($config->get('application_mode') === ApplicationInterface::MODE_PRODUCTION || !$config->get('display_emails_as_messages')) { // Don't mess with emails sending on the production environment, if ($config->get('application_mode') === ApplicationInterface::MODE_PRODUCTION) { return; } // Show emails as messages only when they sent to test users. All other // users will receive emails as usual. if (!empty($config->get('display_emails_as_messages'))) { $test_mail_pattern = '/' . $config->get('test_users_email_prefix') . '.+@' . $config->get('test_users_email_domain') . '/'; if (isset($message['body'][0]) && preg_match($test_mail_pattern, $message['to']) === 1) { $message['send'] = FALSE; Loading @@ -61,22 +64,22 @@ function domino_mail_alter(&$message) { $message_body = Markup::create($bodyWithLinks); } // Show email as Drupal message. \Drupal::messenger()->addStatus($message_body); } // Check enviroment and set config for reroute_email. if ($config->get('application_mode') !== ApplicationInterface::MODE_PRODUCTION) { $settings = \Drupal::configFactory()->get('reroute_email.settings'); $enable = $settings->get('enable'); // If reroute email is not enabled, // then email sending is disabled as fallback. if ($enable === FALSE) { $error = 'Email was not sent: Reroute Email should be enabled for this environment.'; \Drupal::logger('domino')->error($error); // Don't send such emails to test users. $message['send'] = FALSE; } } // If reroute email is not enabled, then for all non-production environments // we disable sending emails. Normally reroute email should be enabled, so // this should not be an issue. $reroute_email_settings = \Drupal::config('reroute_email.settings'); if (!$reroute_email_settings->get('enable')) { \Drupal::logger('domino')->error('Email was not sent: Reroute Email should be enabled for this environment.'); $message['send'] = FALSE; } } /** Loading tests/src/Kernel/RerouteEmailTest.php +0 −1 Original line number Diff line number Diff line Loading @@ -109,7 +109,6 @@ class RerouteEmailTest extends KernelTestBase private function setCurrentEnvironment($env) { $configs = \Drupal::configFactory()->getEditable('domino.settings'); $configs->set('application_mode', $env)->save(); $configs->set('display_emails_as_messages', TRUE)->save(); $this->assertSame($configs->get('application_mode'), $env); } Loading Loading
CHANGELOG.md +2 −1 Original line number Diff line number Diff line Loading @@ -5,8 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased changes - Issue #3314414: Added tests for 'reroute email' functionality. - #3314414: Added tests for 'reroute email' functionality. - #3318273: Make sure tests run on drupal.org infrastructure for the Domino module. - #3323954: Fixed issue with not working fallback for emails rerouting feature. ## [3.2.3] - Fixed bug with installing Reroute Email module on hook_update(). Loading
domino.module +15 −12 Original line number Diff line number Diff line Loading @@ -40,12 +40,15 @@ function domino_cache_flush() { */ function domino_mail_alter(&$message) { $config = \Drupal::config('domino.settings'); if ($config->get('application_mode') === ApplicationInterface::MODE_PRODUCTION || !$config->get('display_emails_as_messages')) { // Don't mess with emails sending on the production environment, if ($config->get('application_mode') === ApplicationInterface::MODE_PRODUCTION) { return; } // Show emails as messages only when they sent to test users. All other // users will receive emails as usual. if (!empty($config->get('display_emails_as_messages'))) { $test_mail_pattern = '/' . $config->get('test_users_email_prefix') . '.+@' . $config->get('test_users_email_domain') . '/'; if (isset($message['body'][0]) && preg_match($test_mail_pattern, $message['to']) === 1) { $message['send'] = FALSE; Loading @@ -61,22 +64,22 @@ function domino_mail_alter(&$message) { $message_body = Markup::create($bodyWithLinks); } // Show email as Drupal message. \Drupal::messenger()->addStatus($message_body); } // Check enviroment and set config for reroute_email. if ($config->get('application_mode') !== ApplicationInterface::MODE_PRODUCTION) { $settings = \Drupal::configFactory()->get('reroute_email.settings'); $enable = $settings->get('enable'); // If reroute email is not enabled, // then email sending is disabled as fallback. if ($enable === FALSE) { $error = 'Email was not sent: Reroute Email should be enabled for this environment.'; \Drupal::logger('domino')->error($error); // Don't send such emails to test users. $message['send'] = FALSE; } } // If reroute email is not enabled, then for all non-production environments // we disable sending emails. Normally reroute email should be enabled, so // this should not be an issue. $reroute_email_settings = \Drupal::config('reroute_email.settings'); if (!$reroute_email_settings->get('enable')) { \Drupal::logger('domino')->error('Email was not sent: Reroute Email should be enabled for this environment.'); $message['send'] = FALSE; } } /** Loading
tests/src/Kernel/RerouteEmailTest.php +0 −1 Original line number Diff line number Diff line Loading @@ -109,7 +109,6 @@ class RerouteEmailTest extends KernelTestBase private function setCurrentEnvironment($env) { $configs = \Drupal::configFactory()->getEditable('domino.settings'); $configs->set('application_mode', $env)->save(); $configs->set('display_emails_as_messages', TRUE)->save(); $this->assertSame($configs->get('application_mode'), $env); } Loading