mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-30 18:45:07 +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;
|
namespace EchoPush;
|
||||||
|
|
||||||
use CentralIdLookup;
|
use CentralIdLookup;
|
||||||
|
use EchoAttributeManager;
|
||||||
use EchoEvent;
|
use EchoEvent;
|
||||||
use JobQueueGroup;
|
use JobQueueGroup;
|
||||||
use User;
|
use User;
|
||||||
|
@ -16,8 +17,12 @@ class PushNotifier {
|
||||||
* @param EchoEvent $event
|
* @param EchoEvent $event
|
||||||
*/
|
*/
|
||||||
public static function notifyWithPush( User $user, EchoEvent $event ): void {
|
public static function notifyWithPush( User $user, EchoEvent $event ): void {
|
||||||
|
$attributeManager = EchoAttributeManager::newFromGlobalVars();
|
||||||
|
$userEnabledEvents = $attributeManager->getUserEnabledEvents( $user, 'push' );
|
||||||
|
if ( in_array( $event->getType(), $userEnabledEvents ) ) {
|
||||||
JobQueueGroup::singleton()->push( self::createJobForUser( $user ) );
|
JobQueueGroup::singleton()->push( self::createJobForUser( $user ) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
|
|
Loading…
Reference in a new issue