56 if ( $recentChange->getAttribute(
'rc_source' ) ===
RecentChange::SRC_CATEGORIZE ) {
60 $config = $mwServices->getMainConfig();
62 $minorEdit = $recentChange->getAttribute(
'rc_minor' );
63 $editor = $mwServices->getUserFactory()
64 ->newFromUserIdentity( $recentChange->getPerformerIdentity() );
66 $title = Title::castFromPageReference( $recentChange->getPage() );
67 if ( $title ===
null || $title->getNamespace() < 0 ) {
74 $watchers = $mwServices->getWatchedItemStore()->updateNotificationTimestamp(
77 $recentChange->getAttribute(
'rc_timestamp' )
81 $sendNotification = $this->shouldSendNotification(
82 $editor, $title, $watchers, $minorEdit, $config
85 if ( $sendNotification ) {
86 $mwServices->getJobQueueGroup()->lazyPush(
new RecentChangeNotifyJob(
90 'editorID' => $editor->
getId(),
91 'watchers' => $watchers,
92 'pageStatus' => $recentChange->mExtra[
'pageStatus'] ??
'changed',
93 'rc_id' => $recentChange->getAttribute(
'rc_id' ),
95 $mwServices->getRecentChangeLookup()
99 return $sendNotification;
150 $pageStatus =
'changed'
152 # we use $wgPasswordSender as sender's address
153 $mwServices = MediaWikiServices::getInstance();
154 $config = $mwServices->getMainConfig();
155 $notifService = $mwServices->getNotificationService();
156 $userFactory = $mwServices->getUserFactory();
157 $hookRunner =
new HookRunner( $mwServices->getHookContainer() );
160 # The following code is only run, if several conditions are met:
161 # 1. RecentChangeNotifier for pages (other than user_talk pages) must be enabled
162 # 2. minor edits (changes) are only regarded if the global flag indicates so
163 $formattedPageStatus = [
'deleted',
'created',
'moved',
'restored',
'changed' ];
164 if ( !in_array( $pageStatus, $formattedPageStatus ) ) {
165 throw new UnexpectedValueException(
'Not a valid page status!' );
167 $agent = $mwServices->getUserFactory()->newFromAuthority( $editor );
171 ( $config->get( MainConfigNames::EnotifMinorEdits ) &&
172 !$editor->
isAllowed(
'nominornewtalk' ) )
174 if ( $config->get( MainConfigNames::EnotifUserTalk )
176 && $this->canSendUserTalkEmail( $editor->
getUser(), $title, $minorEdit )
178 $targetUser = $userFactory->newFromName( $title->getText() );
185 RecentChangeNotification::TALK_NOTIFICATION
187 $notifService->notify( $talkNotification,
new RecipientSet( [ $targetUser ] ) );
188 $userTalkId = $targetUser->getId();
192 if ( $config->get( MainConfigNames::EnotifWatchlist ) ) {
193 $userOptionsLookup = $mwServices->getUserOptionsLookup();
196 $userArray = UserArray::newFromIDs( $watchers );
198 foreach ( $userArray as $watchingUser ) {
199 if ( $userOptionsLookup->
getOption( $watchingUser,
'enotifwatchlistpages' )
200 && ( !$minorEdit || $userOptionsLookup->
getOption( $watchingUser,
'enotifminoredits' ) )
201 && $watchingUser->getId() != $userTalkId
202 && !in_array( $watchingUser->getName(),
203 $config->get( MainConfigNames::UsersNotifiedOnAllChanges ) )
206 && !( $config->get( MainConfigNames::BlockDisablesLogin ) &&
207 $watchingUser->getBlock() )
209 $recipients->addRecipient( $watchingUser );
212 if ( count( $recipients ) !== 0 ) {
218 RecentChangeNotification::WATCHLIST_NOTIFICATION
220 $notifService->notify( $talkNotification, $recipients );
225 foreach ( $config->get( MainConfigNames::UsersNotifiedOnAllChanges ) as $name ) {
227 if ( $editor->
getUser()->getName() == $name ) {
231 $user = $userFactory->newFromName( $name );
232 if ( $user instanceof
User ) {
235 $notifService->notify(
241 RecentChangeNotification::ADMIN_NOTIFICATION