mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-11 17:00:10 +00:00
1d31fd753a
Finishes the implementation of the stubbed NotificationServiceClient. Sends push notification request messages to the endpoint configured in the EchoPushServiceBaseUrl setting. For example, to send messages to an instance of mediawiki/services/push-notifications running on the host machine while running MediaWiki in Docker, add the following line to LocalSettings.php: $wgEchoPushServiceBaseUrl = 'http://172.17.0.1:8900/v1/message'; Bug: T252899 Change-Id: Icab7825e9080d6b1a4cfc5e12fed1da221ce4610
50 lines
1.7 KiB
PHP
50 lines
1.7 KiB
PHP
<?php
|
|
|
|
use EchoPush\NotificationServiceClient;
|
|
use EchoPush\SubscriptionManager;
|
|
use MediaWiki\Logger\LoggerFactory;
|
|
use MediaWiki\MediaWikiServices;
|
|
use MediaWiki\Storage\NameTableStore;
|
|
|
|
return [
|
|
|
|
'EchoPushNotificationServiceClient' => function ( MediaWikiServices $services ):
|
|
NotificationServiceClient {
|
|
$echoConfig = $services->getConfigFactory()->makeConfig( 'Echo' );
|
|
$httpRequestFactory = $services->getHttpRequestFactory();
|
|
$url = $echoConfig->get( 'EchoPushServiceBaseUrl' );
|
|
$client = new NotificationServiceClient( $httpRequestFactory, $url );
|
|
$client->setLogger( LoggerFactory::getInstance( 'Echo' ) );
|
|
return $client;
|
|
},
|
|
|
|
'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 );
|
|
|
|
$centralIdLookup = CentralIdLookup::factory();
|
|
|
|
$pushProviderStore = new NameTableStore(
|
|
$loadBalancer,
|
|
$services->getMainWANObjectCache(),
|
|
LoggerFactory::getInstance( 'Echo' ),
|
|
'echo_push_provider',
|
|
'epp_id',
|
|
'epp_name',
|
|
null,
|
|
$database
|
|
);
|
|
|
|
return new SubscriptionManager( $dbw, $dbr, $centralIdLookup, $pushProviderStore );
|
|
}
|
|
|
|
];
|