Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4147040
ModerationController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ModerationController.php
View Options
<?php
namespace
MediaWiki\Extension\Notifications\Controller
;
use
MediaWiki\Deferred\DeferredUpdates
;
use
MediaWiki\Extension\Notifications\Mapper\EventMapper
;
use
MediaWiki\Extension\Notifications\Mapper\NotificationMapper
;
use
MediaWiki\Extension\Notifications\NotifUser
;
use
MediaWiki\MediaWikiServices
;
use
MediaWiki\User\User
;
/**
* This class represents the controller for moderating notifications
*/
class
ModerationController
{
/**
* Moderate or unmoderate events
*
* @param int[] $eventIds
* @param bool $moderate Whether to moderate or unmoderate the events
*/
public
static
function
moderate
(
array
$eventIds
,
$moderate
)
{
if
(
!
$eventIds
)
{
return
;
}
$eventMapper
=
new
EventMapper
();
$notificationMapper
=
new
NotificationMapper
();
$affectedUserIds
=
$notificationMapper
->
fetchUsersWithNotificationsForEvents
(
$eventIds
);
$eventMapper
->
toggleDeleted
(
$eventIds
,
$moderate
);
$fname
=
__METHOD__
;
DeferredUpdates
::
addCallableUpdate
(
static
function
()
use
(
$affectedUserIds
,
$fname
)
{
// This update runs after the main transaction round commits.
// Wait for the event deletions to be propagated to replica DBs
$lbFactory
=
MediaWikiServices
::
getInstance
()->
getDBLoadBalancerFactory
();
$lbFactory
->
waitForReplication
(
[
'timeout'
=>
5
]
);
$lbFactory
->
flushReplicaSnapshots
(
$fname
);
// Recompute the notification count for the
// users whose notifications have been moderated.
foreach
(
$affectedUserIds
as
$userId
)
{
$user
=
User
::
newFromId
(
$userId
);
NotifUser
::
newFromUser
(
$user
)->
resetNotificationCount
();
}
}
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 19 2026, 18:15 (5 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
1a/9e/060b3dbb3adc3c252b5427b3a28a
Default Alt Text
ModerationController.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment