userFactory = $userFactory; $this->titleFactory = $titleFactory; } public function checkNotificationRequirements( Notification $notification, User $user ): bool { return $user->isEmailConfirmed(); } /** * Notify users about an event occurring. */ public function notify( Notification $notification, RecipientSet $recipients ): void { if ( !$notification instanceof RecentChangeNotification ) { return; } $properties = $notification->getProperties(); $sourceMap = [ RecentChangeNotification::ADMIN_NOTIFICATION => RecentChangeMailComposer::ALL_CHANGES, RecentChangeNotification::TALK_NOTIFICATION => RecentChangeMailComposer::USER_TALK, ]; $source = $sourceMap[ $properties['source'] ] ?? RecentChangeMailComposer::ALL_CHANGES; $composer = new RecentChangeMailComposer( $this->userFactory->newFromUserIdentity( $notification->getAgent() ), $this->titleFactory->newFromPageIdentity( $notification->getTitle() ), $properties['summary'], $properties['minorEdit'], $properties['oldid'], $properties['timestamp'], $properties['pageStatus'] ); foreach ( $recipients as $recipient ) { $user = $this->userFactory->newFromUserIdentity( $recipient ); if ( $this->checkNotificationRequirements( $notification, $user ) ) { $composer->compose( $recipient, $source ); } } // TODO - sendEmails is deprecated, remove it in 1.45. need to keep it in parity in case // EnotifImpersonal is set - then the previous compose doesn't actually send email $composer->sendMails(); } }