mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
4abfbd3c96
* DB changes - Create a table for push topics NameTableStore - Add a foreign key on subscriptions to normalize push topics * Implement NameTableStore to normalize topics * Update DB query joins to include topic from foreignkey * Adapt code to use IDs instead of the actual topic Bug: T261756 Change-Id: Ia7589f4a607993352d45b2dd3bcb3867d12d6e97
67 lines
1.9 KiB
PHP
67 lines
1.9 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 );
|
|
|
|
$pushProviderStore = new NameTableStore(
|
|
$loadBalancer,
|
|
$services->getMainWANObjectCache(),
|
|
LoggerFactory::getInstance( 'Echo' ),
|
|
'echo_push_provider',
|
|
'epp_id',
|
|
'epp_name',
|
|
null,
|
|
$database
|
|
);
|
|
|
|
$pushTopicStore = new NameTableStore(
|
|
$loadBalancer,
|
|
$services->getMainWANObjectCache(),
|
|
LoggerFactory::getInstance( 'Echo' ),
|
|
'echo_push_topic',
|
|
'ept_id',
|
|
'ept_text',
|
|
null,
|
|
$database
|
|
);
|
|
|
|
$maxSubscriptionsPerUser = $echoConfig->get( 'EchoPushMaxSubscriptionsPerUser' );
|
|
|
|
return new SubscriptionManager(
|
|
$dbw,
|
|
$dbr,
|
|
$pushProviderStore,
|
|
$pushTopicStore,
|
|
$maxSubscriptionsPerUser
|
|
);
|
|
}
|
|
|
|
];
|