01tonythomas has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/227648

Change subject: Add an option to disable email notification while defining an 
Echo $notification
......................................................................

Add an option to disable email notification while defining an Echo $notification

Bug: T97925
Change-Id: I1fc529c755d930d4657b7f286669483159756c7d
---
M Notifier.php
M includes/formatters/BasicFormatter.php
2 files changed, 8 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/48/227648/1

diff --git a/Notifier.php b/Notifier.php
index fa4dcb1..4f09dde 100644
--- a/Notifier.php
+++ b/Notifier.php
@@ -31,7 +31,7 @@
         * @return bool
         */
        public static function notifyWithEmail( $user, $event ) {
-               global $wgEnableEmail;
+               global $wgEnableEmail, $wgEchoNotifications;
 
                if ( !$wgEnableEmail ) {
                        return false;
@@ -41,6 +41,11 @@
                        return false;
                }
 
+               // The user might turn off email notification for this 
particular event
+               if( 
!$wgEchoNotifications[$event->getType()]['email-notification'] ) {
+                       return false;
+               }
+
                // Final check on whether to send email for this user & event
                if ( !Hooks::run( 'EchoAbortEmailNotification', array( $user, 
$event ) ) ) {
                        return false;
diff --git a/includes/formatters/BasicFormatter.php 
b/includes/formatters/BasicFormatter.php
index d973acb..c8cc0d5 100644
--- a/includes/formatters/BasicFormatter.php
+++ b/includes/formatters/BasicFormatter.php
@@ -98,6 +98,7 @@
 
                // Notification email subject and body
                $this->email = array(
+                       'notification' => $params['email-notification'],
                        'subject' => array(
                                'message' => $params['email-subject-message'],
                                'params' => $params['email-subject-params']
@@ -127,6 +128,7 @@
                        'bundle-message' => '',
                        'bundle-params' => array(),
                        'payload' => array(),
+                       'email-notification' => true,
                        'email-subject-message' => 'echo-email-subject-default',
                        'email-subject-params' => array(),
                        'email-body-batch-message' => 
'echo-email-batch-body-default',

-- 
To view, visit https://gerrit.wikimedia.org/r/227648
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1fc529c755d930d4657b7f286669483159756c7d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: 01tonythomas <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to