74 if ( $recentChange->getAttribute(
'rc_source' ) ===
RecentChange::SRC_CATEGORIZE ) {
78 $config = $mwServices->getMainConfig();
80 $minorEdit = $recentChange->getAttribute(
'rc_minor' );
81 $editor = $mwServices->getUserFactory()
82 ->newFromUserIdentity( $recentChange->getPerformerIdentity() );
84 $title = Title::castFromPageReference( $recentChange->getPage() );
85 if ( $title ===
null || $title->getNamespace() < 0 ) {
92 $watchers = $mwServices->getWatchedItemStore()->updateNotificationTimestamp(
95 $recentChange->getAttribute(
'rc_timestamp' )
99 $sendNotification = $this->shouldSendNotification(
100 $editor, $title, $watchers, $minorEdit, $config
103 if ( $sendNotification ) {
104 $mwServices->getJobQueueGroup()->lazyPush(
new RecentChangeNotifyJob(
107 'editor' => $editor->
getName(),
108 'editorID' => $editor->
getId(),
109 'watchers' => $watchers,
110 'pageStatus' => $recentChange->mExtra[
'pageStatus'] ??
'changed',
111 'rc_id' => $recentChange->getAttribute(
'rc_id' ),
113 $mwServices->getRecentChangeLookup()
117 return $sendNotification;
168 $pageStatus =
'changed'
170 # we use $wgPasswordSender as sender's address
171 $mwServices = MediaWikiServices::getInstance();
172 $config = $mwServices->getMainConfig();
173 $notifService = $mwServices->getNotificationService();
174 $userFactory = $mwServices->getUserFactory();
175 $hookRunner =
new HookRunner( $mwServices->getHookContainer() );
178 # The following code is only run, if several conditions are met:
179 # 1. RecentChangeNotifier for pages (other than user_talk pages) must be enabled
180 # 2. minor edits (changes) are only regarded if the global flag indicates so
181 $this->pageStatus = $pageStatus;
182 $formattedPageStatus = [
'deleted',
'created',
'moved',
'restored',
'changed' ];
184 $hookRunner->onUpdateUserMailerFormattedPageStatus( $formattedPageStatus );
185 if ( !in_array( $this->pageStatus, $formattedPageStatus ) ) {
186 throw new UnexpectedValueException(
'Not a valid page status!' );
188 $agent = $mwServices->getUserFactory()->newFromAuthority( $editor );
192 ( $config->get( MainConfigNames::EnotifMinorEdits ) &&
193 !$editor->
isAllowed(
'nominornewtalk' ) )
195 if ( $config->get( MainConfigNames::EnotifUserTalk )
197 && $this->canSendUserTalkEmail( $editor->
getUser(), $title, $minorEdit )
199 $targetUser = $userFactory->newFromName( $title->getText() );
206 RecentChangeNotification::TALK_NOTIFICATION
208 $notifService->notify( $talkNotification,
new RecipientSet( [ $targetUser ] ) );
209 $userTalkId = $targetUser->getId();
213 if ( $config->get( MainConfigNames::EnotifWatchlist ) ) {
214 $userOptionsLookup = $mwServices->getUserOptionsLookup();
217 $userArray = UserArray::newFromIDs( $watchers );
219 foreach ( $userArray as $watchingUser ) {
220 if ( $userOptionsLookup->
getOption( $watchingUser,
'enotifwatchlistpages' )
221 && ( !$minorEdit || $userOptionsLookup->
getOption( $watchingUser,
'enotifminoredits' ) )
222 && $watchingUser->getId() != $userTalkId
223 && !in_array( $watchingUser->getName(),
224 $config->get( MainConfigNames::UsersNotifiedOnAllChanges ) )
227 && !( $config->get( MainConfigNames::BlockDisablesLogin ) &&
228 $watchingUser->getBlock() )
229 && $hookRunner->onSendWatchlistEmailNotification( $watchingUser, $title, $this )
231 $recipients->addRecipient( $watchingUser );
234 if ( count( $recipients ) !== 0 ) {
240 RecentChangeNotification::WATCHLIST_NOTIFICATION
242 $notifService->notify( $talkNotification, $recipients );
247 foreach ( $config->get( MainConfigNames::UsersNotifiedOnAllChanges ) as $name ) {
249 if ( $editor->
getUser()->getName() == $name ) {
253 $user = $userFactory->newFromName( $name );
254 if ( $user instanceof
User ) {
257 $notifService->notify(
263 RecentChangeNotification::ADMIN_NOTIFICATION