2020-05-15 17:19:03 +00:00
|
|
|
<?php
|
|
|
|
|
2020-05-22 22:02:34 +00:00
|
|
|
use EchoPush\NotificationServiceClient;
|
2020-05-15 17:19:03 +00:00
|
|
|
use EchoPush\SubscriptionManager;
|
|
|
|
use MediaWiki\Logger\LoggerFactory;
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
use MediaWiki\Storage\NameTableStore;
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
2020-05-22 22:02:34 +00:00
|
|
|
'EchoPushNotificationServiceClient' => function ( MediaWikiServices $services ):
|
|
|
|
NotificationServiceClient {
|
|
|
|
$echoConfig = $services->getConfigFactory()->makeConfig( 'Echo' );
|
|
|
|
$httpRequestFactory = $services->getHttpRequestFactory();
|
2020-06-02 23:21:36 +00:00
|
|
|
$url = $echoConfig->get( 'EchoPushServiceBaseUrl' );
|
2020-05-22 22:02:34 +00:00
|
|
|
$client = new NotificationServiceClient( $httpRequestFactory, $url );
|
|
|
|
$client->setLogger( LoggerFactory::getInstance( 'Echo' ) );
|
|
|
|
return $client;
|
|
|
|
},
|
|
|
|
|
2020-05-15 17:19:03 +00:00
|
|
|
'EchoPushSubscriptionManager' => function ( MediaWikiServices $services ): SubscriptionManager {
|
|
|
|
$echoConfig = $services->getConfigFactory()->makeConfig( 'Echo' );
|
|
|
|
// Use shared DB/cluster for push subscriptions
|
|
|
|
$cluster = $echoConfig->get( 'EchoSharedTrackingCluster' );
|
|
|
|
$database = $echoConfig->get( 'EchoSharedTrackingDB' );
|
|
|
|
$loadBalancerFactory = $services->getDBLoadBalancerFactory();
|
|
|
|
$loadBalancer = $cluster
|
|
|
|
? $loadBalancerFactory->getExternalLB( $cluster )
|
|
|
|
: $loadBalancerFactory->getMainLB( $database );
|
|
|
|
$dbw = $loadBalancer->getLazyConnectionRef( DB_MASTER, [], $database );
|
|
|
|
$dbr = $loadBalancer->getLazyConnectionRef( DB_REPLICA, [], $database );
|
|
|
|
|
|
|
|
$pushProviderStore = new NameTableStore(
|
|
|
|
$loadBalancer,
|
|
|
|
$services->getMainWANObjectCache(),
|
|
|
|
LoggerFactory::getInstance( 'Echo' ),
|
|
|
|
'echo_push_provider',
|
|
|
|
'epp_id',
|
|
|
|
'epp_name',
|
|
|
|
null,
|
|
|
|
$database
|
|
|
|
);
|
|
|
|
|
2020-09-08 13:34:54 +00:00
|
|
|
$pushTopicStore = new NameTableStore(
|
|
|
|
$loadBalancer,
|
|
|
|
$services->getMainWANObjectCache(),
|
|
|
|
LoggerFactory::getInstance( 'Echo' ),
|
|
|
|
'echo_push_topic',
|
|
|
|
'ept_id',
|
|
|
|
'ept_text',
|
|
|
|
null,
|
|
|
|
$database
|
|
|
|
);
|
|
|
|
|
2020-08-12 21:33:06 +00:00
|
|
|
$maxSubscriptionsPerUser = $echoConfig->get( 'EchoPushMaxSubscriptionsPerUser' );
|
|
|
|
|
2020-09-08 13:34:54 +00:00
|
|
|
return new SubscriptionManager(
|
|
|
|
$dbw,
|
|
|
|
$dbr,
|
|
|
|
$pushProviderStore,
|
|
|
|
$pushTopicStore,
|
|
|
|
$maxSubscriptionsPerUser
|
|
|
|
);
|
2020-05-15 17:19:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
];
|