Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
QueryMessageGroupSubscriptionApi.php
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\MessageGroupProcessing;
5
6use ApiQuery;
7use ApiQueryBase;
8
16class QueryMessageGroupSubscriptionApi extends ApiQueryBase {
17 private MessageGroupSubscription $groupSubscription;
18
19 public function __construct(
20 ApiQuery $queryModule,
21 string $moduleName,
22 MessageGroupSubscription $groupSubscription
23 ) {
24 parent::__construct( $queryModule, $moduleName, 'qmgs' );
25 $this->groupSubscription = $groupSubscription;
26 }
27
28 public function execute(): void {
29 if ( !$this->groupSubscription->isEnabled() ) {
30 $this->dieWithError( 'apierror-translate-messagegroupsubscription-disabled' );
31 }
32 $watchedMessageGroups = $this->groupSubscription->getUserSubscriptions( $this->getUser() );
33 $result = $this->getResult();
34 $result->addValue( [ 'query' ], $this->getModuleName(), $watchedMessageGroups );
35 }
36
37 public function isInternal(): bool {
38 return true;
39 }
40}
Manage user subscriptions to message groups and trigger notifications.