mediawiki-extensions-Echo/includes/Push/NotificationRequestJob.php
Michael Holloway 657e914513 Push: Bail out of notification job early if no subscriptions found
Change-Id: Ica8e5c0496171dba4315c27072c2d865eb747e78
2020-06-10 15:38:23 -04:00

27 lines
617 B
PHP

<?php
namespace EchoPush;
use EchoServices;
use Job;
class NotificationRequestJob extends Job {
/**
* @return bool success
*/
public function run(): bool {
$centralId = $this->params['centralId'];
$echoServices = EchoServices::getInstance();
$subscriptionManager = $echoServices->getPushSubscriptionManager();
$subscriptions = $subscriptionManager->getSubscriptionsForUser( $centralId );
if ( count( $subscriptions ) === 0 ) {
return true;
}
$serviceClient = $echoServices->getPushNotificationServiceClient();
$serviceClient->sendCheckEchoRequests( $subscriptions );
return true;
}
}