mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
Push: Check that the event type is enabled before scheduling job
It is the notifier implementation's responsibility to check the user's notification preferences before sending a notification. This adds the check. Change-Id: I4b7fd7ea444f5a6db6d79fadb48a440d4fdf0ac9
This commit is contained in:
parent
6bd34b6765
commit
07c8c0afcf
|
@ -3,6 +3,7 @@
|
|||
namespace EchoPush;
|
||||
|
||||
use CentralIdLookup;
|
||||
use EchoAttributeManager;
|
||||
use EchoEvent;
|
||||
use JobQueueGroup;
|
||||
use User;
|
||||
|
@ -16,7 +17,11 @@ class PushNotifier {
|
|||
* @param EchoEvent $event
|
||||
*/
|
||||
public static function notifyWithPush( User $user, EchoEvent $event ): void {
|
||||
JobQueueGroup::singleton()->push( self::createJobForUser( $user ) );
|
||||
$attributeManager = EchoAttributeManager::newFromGlobalVars();
|
||||
$userEnabledEvents = $attributeManager->getUserEnabledEvents( $user, 'push' );
|
||||
if ( in_array( $event->getType(), $userEnabledEvents ) ) {
|
||||
JobQueueGroup::singleton()->push( self::createJobForUser( $user ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue