mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 16:04:35 +00:00
24caf50ff6
To allow individual notifications to be marked as read/unread or moderated, bundles are created by grouping associated notifications when they are fetched for display instead of when they are created. From a product perspective, this change doesn't introduce moderation or expandable bundles but it counts each individual notifications. For instance, the bundled notification "3 new topics on PageA" now counts as 3 notifications. Bug: T93673 Bug: T120153 Change-Id: Iacd098573efd92bb1e3fcd7da4cd40cea9522f15
36 lines
899 B
PHP
36 lines
899 B
PHP
<?php
|
|
|
|
/**
|
|
* This class represents the controller for moderating notifications
|
|
*/
|
|
class EchoModerationController {
|
|
|
|
/**
|
|
* Moderate or unmoderate events
|
|
*
|
|
* @param int[] $eventIds
|
|
* @param bool $moderate Whether to moderate or unmoderate the events
|
|
* @throws MWException
|
|
*/
|
|
public static function moderate( $eventIds, $moderate ) {
|
|
if ( !$eventIds ) {
|
|
return;
|
|
}
|
|
|
|
$eventMapper = new EchoEventMapper();
|
|
$notificationMapper = new EchoNotificationMapper();
|
|
|
|
$affectedUserIds = $notificationMapper->fetchUsersWithNotificationsForEvents( $eventIds );
|
|
$eventMapper->toggleDeleted( $eventIds, $moderate );
|
|
|
|
/**
|
|
* Recompute the notification count for the
|
|
* users whose notifications have been moderated.
|
|
*/
|
|
foreach ( $affectedUserIds as $userId ) {
|
|
$user = User::newFromId( $userId );
|
|
MWEchoNotifUser::newFromUser( $user )->resetNotificationCount();
|
|
}
|
|
}
|
|
}
|