mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-25 00:05:29 +00:00
48ca4aeb5e
At the time that resetNotificationCount() is called, we've only just moderated something, so the slave won't have those changes yet, and the computed notification count will be wrong. Change-Id: Ia83f2b9cf7f4bbaee25e03f7bc8f73bcd4d345f9
36 lines
910 B
PHP
36 lines
910 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( DB_MASTER );
|
|
}
|
|
}
|
|
}
|