From 578b63354bed235883c919447c8f147512bb8833 Mon Sep 17 00:00:00 2001 From: rpnykanen Date: Thu, 7 Sep 2023 12:39:06 +0300 Subject: [PATCH 1/4] UHF-8945: disable email sending. Cron tries to send update reminder email every time which floods sentry with hundreds of error messages daily.('reply-to not set' -error) --- helfi_api_base.module | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/helfi_api_base.module b/helfi_api_base.module index 943fbcbd..875c494c 100644 --- a/helfi_api_base.module +++ b/helfi_api_base.module @@ -50,3 +50,16 @@ function helfi_api_base_theme_suggestions_debug_item(array $variables) : array { $suggestions[] = 'debug_item__' . strtr($variables['id'], '.', '_'); return $suggestions; } + +/** + * Implements hook_mail_alter(). + */ +function helfi_api_base_mail_alter(&$message) : void { + $environmentResolver = \Drupal::service('helfi_api_base.environment_resolver'); + try { + $environmentResolver->getActiveEnvironment(); + $message['send'] = FALSE; + } + catch (\InvalidArgumentException) { + } +} From d825bc2063e6a310a4cc4d3887c7641144bcd20c Mon Sep 17 00:00:00 2001 From: rpnykanen Date: Fri, 8 Sep 2023 08:52:59 +0300 Subject: [PATCH 2/4] UHF-8945: added comment, unecesary use of variable --- helfi_api_base.module | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/helfi_api_base.module b/helfi_api_base.module index 875c494c..99be4a93 100644 --- a/helfi_api_base.module +++ b/helfi_api_base.module @@ -55,9 +55,11 @@ function helfi_api_base_theme_suggestions_debug_item(array $variables) : array { * Implements hook_mail_alter(). */ function helfi_api_base_mail_alter(&$message) : void { - $environmentResolver = \Drupal::service('helfi_api_base.environment_resolver'); + // Prevent sending an email if current site/environment is unknown to the resolver. + // Only helfi-drupal sites are affected by this change. try { - $environmentResolver->getActiveEnvironment(); + \Drupal::service('helfi_api_base.environment_resolver') + ->getActiveEnvironment(); $message['send'] = FALSE; } catch (\InvalidArgumentException) { From edfb3892a54c07cdc694279eb5efcfbadb186484 Mon Sep 17 00:00:00 2001 From: rpnykanen Date: Fri, 8 Sep 2023 08:54:17 +0300 Subject: [PATCH 3/4] UHF-8945: correction to the comment --- helfi_api_base.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helfi_api_base.module b/helfi_api_base.module index 99be4a93..3c23080c 100644 --- a/helfi_api_base.module +++ b/helfi_api_base.module @@ -55,7 +55,7 @@ function helfi_api_base_theme_suggestions_debug_item(array $variables) : array { * Implements hook_mail_alter(). */ function helfi_api_base_mail_alter(&$message) : void { - // Prevent sending an email if current site/environment is unknown to the resolver. + // Prevent sending an email if current site/environment is known to the resolver. // Only helfi-drupal sites are affected by this change. try { \Drupal::service('helfi_api_base.environment_resolver') From d142c9edba3247db5a499c8e24224fa1dd4897f0 Mon Sep 17 00:00:00 2001 From: rpnykanen Date: Fri, 8 Sep 2023 08:57:10 +0300 Subject: [PATCH 4/4] UHF-8945: line exceeded 80 chars --- helfi_api_base.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helfi_api_base.module b/helfi_api_base.module index 3c23080c..b14d5494 100644 --- a/helfi_api_base.module +++ b/helfi_api_base.module @@ -55,7 +55,7 @@ function helfi_api_base_theme_suggestions_debug_item(array $variables) : array { * Implements hook_mail_alter(). */ function helfi_api_base_mail_alter(&$message) : void { - // Prevent sending an email if current site/environment is known to the resolver. + // Prevent sending email if current site/environment is known to the resolver. // Only helfi-drupal sites are affected by this change. try { \Drupal::service('helfi_api_base.environment_resolver')