mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
15d48278be
Creates a EchoPushMaxSubscriptionsPerUser config setting (default: 0) that controls the maximum number of subscriptions a user may associate with the user's central user ID. The setting is enforced in EchoPush\SubscriptionManager::create(). To allow creating push subscriptions for development, set $wgEchoPushMaxSubscriptionsPerUser to a positive integer value in LocalSettings.php: $wgEchoPushMaxSubscriptionsPerUser = 10; Bug: T259150 Change-Id: Ib97b6b6cbb8161dd75dad92c54b4fe4fff80c421
53 lines
1.8 KiB
PHP
53 lines
1.8 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
|
|
);
|
|
|
|
$maxSubscriptionsPerUser = $echoConfig->get( 'EchoPushMaxSubscriptionsPerUser' );
|
|
|
|
return new SubscriptionManager( $dbw, $dbr, $centralIdLookup, $pushProviderStore,
|
|
$maxSubscriptionsPerUser );
|
|
}
|
|
|
|
];
|