2020-05-15 17:19:03 +00:00
|
|
|
<?php
|
|
|
|
|
2022-04-08 00:38:27 +00:00
|
|
|
use MediaWiki\Extension\Notifications\Push\NotificationServiceClient;
|
|
|
|
use MediaWiki\Extension\Notifications\Push\SubscriptionManager;
|
2020-05-15 17:19:03 +00:00
|
|
|
use MediaWiki\Logger\LoggerFactory;
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
use MediaWiki\Storage\NameTableStore;
|
|
|
|
|
2022-12-24 00:44:29 +00:00
|
|
|
// PHP unit does not understand code coverage for this file
|
|
|
|
// as the @covers annotation cannot cover a specific file.
|
|
|
|
// Whether the services return without error is checked in ServiceWiringTest.php
|
|
|
|
// @codeCoverageIgnoreStart
|
|
|
|
|
2020-05-15 17:19:03 +00:00
|
|
|
return [
|
|
|
|
|
2021-05-04 16:06:42 +00:00
|
|
|
'EchoAttributeManager' => static function ( MediaWikiServices $services ): EchoAttributeManager {
|
2021-02-25 02:46:03 +00:00
|
|
|
$userGroupManager = $services->getUserGroupManager();
|
2021-02-25 01:55:40 +00:00
|
|
|
$echoConfig = $services->getConfigFactory()->makeConfig( 'Echo' );
|
|
|
|
$notifications = $echoConfig->get( 'EchoNotifications' );
|
|
|
|
$categories = $echoConfig->get( 'EchoNotificationCategories' );
|
|
|
|
$typeAvailability = $echoConfig->get( 'DefaultNotifyTypeAvailability' );
|
|
|
|
$typeAvailabilityByCategory = $echoConfig->get( 'NotifyTypeAvailabilityByCategory' );
|
2021-02-25 02:46:03 +00:00
|
|
|
|
|
|
|
return new EchoAttributeManager(
|
|
|
|
$notifications,
|
|
|
|
$categories,
|
|
|
|
$typeAvailability,
|
|
|
|
$typeAvailabilityByCategory,
|
2021-06-29 06:26:58 +00:00
|
|
|
$userGroupManager,
|
|
|
|
$services->getUserOptionsLookup()
|
2021-02-25 02:46:03 +00:00
|
|
|
);
|
2021-02-25 01:55:40 +00:00
|
|
|
},
|
|
|
|
|
2021-07-24 04:10:29 +00:00
|
|
|
'EchoPushNotificationServiceClient' => static function (
|
|
|
|
MediaWikiServices $services
|
|
|
|
): NotificationServiceClient {
|
2020-05-22 22:02:34 +00:00
|
|
|
$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;
|
|
|
|
},
|
|
|
|
|
2021-05-04 16:06:42 +00:00
|
|
|
'EchoPushSubscriptionManager' => static function ( MediaWikiServices $services ): SubscriptionManager {
|
2020-05-15 17:19:03 +00:00
|
|
|
$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 );
|
2022-03-03 12:23:30 +00:00
|
|
|
$dbw = $loadBalancer->getConnectionRef( DB_PRIMARY, [], $database );
|
|
|
|
$dbr = $loadBalancer->getConnectionRef( DB_REPLICA, [], $database );
|
2020-05-15 17:19:03 +00:00
|
|
|
|
|
|
|
$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
|
|
|
}
|
|
|
|
|
|
|
|
];
|
2022-12-24 00:44:29 +00:00
|
|
|
|
|
|
|
// @codeCoverageIgnoreEnd
|