diff options
author | ArtBaltai <art.baltai@speedandfunction.com> | 2020-05-13 06:54:09 +0300 |
---|---|---|
committer | James D. Forrester <jforrester@wikimedia.org> | 2023-11-06 09:17:54 -0500 |
commit | 012a4a93ff5ecba3b88f3e9e70821b606d97a4ae (patch) | |
tree | 3bff7be892473e3f972944a1ee5cb3620a78697d /includes/mail | |
parent | e88f4d264e8b1ea71c91e7b1966442b6e0948621 (diff) | |
download | mediawikicore-012a4a93ff5ecba3b88f3e9e70821b606d97a4ae.tar.gz mediawikicore-012a4a93ff5ecba3b88f3e9e70821b606d97a4ae.zip |
Use Emailer class instead of UserMailer
Bug: T247393
Change-Id: I5d682d434b4bc1dc0fa040b91854ef1a43779473
Diffstat (limited to 'includes/mail')
-rw-r--r-- | includes/mail/EmailNotification.php | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/includes/mail/EmailNotification.php b/includes/mail/EmailNotification.php index 12671005401b..006c7ef142e0 100644 --- a/includes/mail/EmailNotification.php +++ b/includes/mail/EmailNotification.php @@ -30,7 +30,6 @@ use MediaWiki\MainConfigNames; use MediaWiki\MediaWikiServices; use MediaWiki\Permissions\Authority; use MediaWiki\SpecialPage\SpecialPage; -use MediaWiki\Status\Status; use MediaWiki\Title\Title; use MediaWiki\User\User; use MediaWiki\User\UserArray; @@ -521,9 +520,9 @@ class EmailNotification { * * @param UserEmailContact $watchingUser * @param string $source - * @return Status + * @return StatusValue */ - private function sendPersonalised( UserEmailContact $watchingUser, $source ) { + private function sendPersonalised( UserEmailContact $watchingUser, $source ): StatusValue { // From the PHP manual: // Note: The to parameter cannot be an address in the form of // "Something <someone@example.com>". The mail command will not parse @@ -558,24 +557,33 @@ class EmailNotification { $headers['List-Help'] = 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Watchlist'; } - return UserMailer::send( $to, $this->from, $this->subject, $body, [ - 'replyTo' => $this->replyto, - 'headers' => $headers, - ] ); + return $mwServices + ->getEmailer() + ->send( + [ $to ], + $this->from, + $this->subject, + $body, + null, + [ + 'replyTo' => $this->replyto, + 'headers' => $headers, + ] + ); } /** * Same as sendPersonalised but does impersonal mail suitable for bulk * mailing. Takes an array of MailAddress objects. * @param MailAddress[] $addresses - * @return Status|null + * @return ?StatusValue */ - private function sendImpersonal( $addresses ) { - if ( !$addresses ) { + private function sendImpersonal( array $addresses ): ?StatusValue { + if ( count( $addresses ) === 0 ) { return null; } - - $contLang = MediaWikiServices::getInstance()->getContentLanguage(); + $services = MediaWikiServices::getInstance(); + $contLang = $services->getContentLanguage(); $body = str_replace( [ '$WATCHINGUSERNAME', @@ -590,9 +598,18 @@ class EmailNotification { $this->body ); - return UserMailer::send( $addresses, $this->from, $this->subject, $body, [ - 'replyTo' => $this->replyto, - ] ); + return $services + ->getEmailer() + ->send( + $addresses, + $this->from, + $this->subject, + $body, + null, + [ + 'replyTo' => $this->replyto, + ] + ); } } |