57 if ( $recentChange->getAttribute(
'rc_source' ) ===
RecentChange::SRC_CATEGORIZE ) {
61 $config = $mwServices->getMainConfig();
63 $minorEdit = $recentChange->getAttribute(
'rc_minor' );
64 $editor = $mwServices->getUserFactory()
65 ->newFromUserIdentity( $recentChange->getPerformerIdentity() );
67 $title = Title::castFromPageReference( $recentChange->getPage() );
68 if ( $title ===
null || $title->getNamespace() < 0 ) {
75 $watchers = $mwServices->getWatchedItemStore()->updateNotificationTimestamp(
78 $recentChange->getAttribute(
'rc_timestamp' )
82 $sendNotification = $this->shouldSendNotification(
83 $editor, $title, $watchers, $minorEdit, $config
86 if ( $sendNotification ) {
87 $mwServices->getJobQueueGroup()->lazyPush(
new RecentChangeNotifyJob(
91 'editorID' => $editor->
getId(),
92 'watchers' => $watchers,
93 'pageStatus' => $recentChange->mExtra[
'pageStatus'] ??
'changed',
94 'rc_id' => $recentChange->getAttribute(
'rc_id' ),
96 $mwServices->getRecentChangeLookup()
100 return $sendNotification;
151 $pageStatus =
'changed'
153 # we use $wgPasswordSender as sender's address
154 $mwServices = MediaWikiServices::getInstance();
155 $config = $mwServices->getMainConfig();
156 $notifService = $mwServices->getNotificationService();
157 $userFactory = $mwServices->getUserFactory();
158 $hookRunner =
new HookRunner( $mwServices->getHookContainer() );
161 # The following code is only run, if several conditions are met:
162 # 1. RecentChangeNotifier for pages (other than user_talk pages) must be enabled
163 # 2. minor edits (changes) are only regarded if the global flag indicates so
164 $formattedPageStatus = [
'deleted',
'created',
'moved',
'restored',
'changed' ];
165 if ( !in_array( $pageStatus, $formattedPageStatus ) ) {
166 throw new UnexpectedValueException(
'Not a valid page status!' );
168 $agent = $mwServices->getUserFactory()->newFromAuthority( $editor );
172 ( $config->get( MainConfigNames::EnotifMinorEdits ) &&
173 !$editor->
isAllowed(
'nominornewtalk' ) )
175 if ( $config->get( MainConfigNames::EnotifUserTalk )
177 && $this->canSendUserTalkEmail( $editor->
getUser(), $title, $minorEdit )
179 $targetUser = $userFactory->newFromName( $title->getText() );
186 RecentChangeNotification::TALK_NOTIFICATION
188 $notifService->notify( $talkNotification,
new RecipientSet( [ $targetUser ] ) );
189 $userTalkId = $targetUser->getId();
193 if ( $config->get( MainConfigNames::EnotifWatchlist ) ) {
194 $userOptionsLookup = $mwServices->getUserOptionsLookup();
197 $userArray = UserArray::newFromIDs( $watchers );
199 foreach ( $userArray as $watchingUser ) {
200 if ( $userOptionsLookup->
getOption( $watchingUser,
'enotifwatchlistpages' )
201 && ( !$minorEdit || $userOptionsLookup->
getOption( $watchingUser,
'enotifminoredits' ) )
202 && $watchingUser->getId() != $userTalkId
203 && !in_array( $watchingUser->getName(),
204 $config->get( MainConfigNames::UsersNotifiedOnAllChanges ) )
207 && !( $config->get( MainConfigNames::BlockDisablesLogin ) &&
208 $watchingUser->getBlock() )
210 $recipients->addRecipient( $watchingUser );
213 if ( count( $recipients ) !== 0 ) {
219 RecentChangeNotification::WATCHLIST_NOTIFICATION
221 $notifService->notify( $talkNotification, $recipients );
226 foreach ( $config->get( MainConfigNames::UsersNotifiedOnAllChanges ) as $name ) {
228 if ( $editor->
getUser()->getName() == $name ) {
232 $user = $userFactory->newFromName( $name );
233 if ( $user instanceof
User ) {
236 $notifService->notify(
242 RecentChangeNotification::ADMIN_NOTIFICATION