| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
use MediaWiki\HookContainer\HookRunner; |
| 26 |
use MediaWiki\Mail\UserEmailContact; |
| 27 |
use MediaWiki\MainConfigNames; |
| 28 |
use MediaWiki\MediaWikiServices; |
| 29 |
use MediaWiki\Permissions\Authority; |
| 30 |
use MediaWiki\SpecialPage\SpecialPage; |
| 31 |
use MediaWiki\Title\Title; |
| 32 |
use MediaWiki\User\User; |
| 33 |
use MediaWiki\User\UserArray; |
| 34 |
use MediaWiki\User\UserIdentity; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
class EmailNotification { |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
private const USER_TALK = 'user_talk'; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
private const WATCHLIST = 'watchlist'; |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
private const ALL_CHANGES = 'all_changes'; |
| 75 |
|
| 76 |
protected string $subject = ''; |
| 77 |
|
| 78 |
protected string $body = ''; |
| 79 |
|
| 80 |
protected ?MailAddress $replyto; |
| 81 |
|
| 82 |
protected ?MailAddress $from; |
| 83 |
|
| 84 |
protected ?string $timestamp; |
| 85 |
|
| 86 |
protected string $summary = ''; |
| 87 |
|
| 88 |
protected ?bool $minorEdit; |
| 89 |
|
| 90 |
|
| 91 |
protected $oldid; |
| 92 |
|
| 93 |
protected bool $composed_common = false; |
| 94 |
|
| 95 |
protected string $pageStatus = ''; |
| 96 |
|
| 97 |
|
| 98 |
protected array $mailTargets = []; |
| 99 |
|
| 100 |
protected Title $title; |
| 101 |
|
| 102 |
protected User $editor; |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
public function getPageStatus() { |
| 115 |
return $this->pageStatus; |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
public function notifyOnPageChange( |
| 135 |
Authority $editor, |
| 136 |
$title, |
| 137 |
$timestamp, |
| 138 |
$summary, |
| 139 |
$minorEdit, |
| 140 |
$oldid = false, |
| 141 |
$pageStatus = 'changed' |
| 142 |
): bool { |
| 143 |
if ( $title->getNamespace() < 0 ) { |
| 144 |
return false; |
| 145 |
} |
| 146 |
|
| 147 |
$mwServices = MediaWikiServices::getInstance(); |
| 148 |
$config = $mwServices->getMainConfig(); |
| 149 |
|
| 150 |
|
| 151 |
$watchers = []; |
| 152 |
if ( $config->get( MainConfigNames::EnotifWatchlist ) || $config->get( MainConfigNames::ShowUpdatedMarker ) ) { |
| 153 |
$watchers = $mwServices->getWatchedItemStore()->updateNotificationTimestamp( |
| 154 |
$editor->getUser(), |
| 155 |
$title, |
| 156 |
$timestamp |
| 157 |
); |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
if ( $mwServices->getUserFactory()->newFromAuthority( $editor )->isBot() ) { |
| 162 |
return false; |
| 163 |
} |
| 164 |
|
| 165 |
$sendEmail = true; |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
if ( $watchers === [] && |
| 171 |
!count( $config->get( MainConfigNames::UsersNotifiedOnAllChanges ) ) |
| 172 |
) { |
| 173 |
$sendEmail = false; |
| 174 |
|
| 175 |
if ( !$minorEdit || |
| 176 |
( $config->get( MainConfigNames::EnotifMinorEdits ) && |
| 177 |
!$editor->isAllowed( 'nominornewtalk' ) ) |
| 178 |
) { |
| 179 |
if ( $config->get( MainConfigNames::EnotifUserTalk ) |
| 180 |
&& $title->getNamespace() === NS_USER_TALK |
| 181 |
&& $this->canSendUserTalkEmail( $editor->getUser(), $title, $minorEdit ) |
| 182 |
) { |
| 183 |
$sendEmail = true; |
| 184 |
} |
| 185 |
} |
| 186 |
} |
| 187 |
|
| 188 |
if ( $sendEmail ) { |
| 189 |
$mwServices->getJobQueueGroup()->lazyPush( new EnotifNotifyJob( |
| 190 |
$title, |
| 191 |
[ |
| 192 |
'editor' => $editor->getUser()->getName(), |
| 193 |
'editorID' => $editor->getUser()->getId(), |
| 194 |
'timestamp' => $timestamp, |
| 195 |
'summary' => $summary, |
| 196 |
'minorEdit' => $minorEdit, |
| 197 |
'oldid' => $oldid, |
| 198 |
'watchers' => $watchers, |
| 199 |
'pageStatus' => $pageStatus |
| 200 |
] |
| 201 |
) ); |
| 202 |
} |
| 203 |
|
| 204 |
return $sendEmail; |
| 205 |
} |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
public function actuallyNotifyOnPageChange( |
| 225 |
Authority $editor, |
| 226 |
$title, |
| 227 |
$timestamp, |
| 228 |
$summary, |
| 229 |
$minorEdit, |
| 230 |
$oldid, |
| 231 |
$watchers, |
| 232 |
$pageStatus = 'changed' |
| 233 |
) { |
| 234 |
|
| 235 |
|
| 236 |
$mwServices = MediaWikiServices::getInstance(); |
| 237 |
$messageCache = $mwServices->getMessageCache(); |
| 238 |
$config = $mwServices->getMainConfig(); |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
$this->title = $title; |
| 245 |
$this->timestamp = $timestamp; |
| 246 |
$this->summary = $summary; |
| 247 |
$this->minorEdit = $minorEdit; |
| 248 |
$this->oldid = $oldid; |
| 249 |
$this->editor = MediaWikiServices::getInstance()->getUserFactory()->newFromAuthority( $editor ); |
| 250 |
$this->composed_common = false; |
| 251 |
$this->pageStatus = $pageStatus; |
| 252 |
|
| 253 |
$formattedPageStatus = [ 'deleted', 'created', 'moved', 'restored', 'changed' ]; |
| 254 |
|
| 255 |
$hookRunner = new HookRunner( $mwServices->getHookContainer() ); |
| 256 |
$hookRunner->onUpdateUserMailerFormattedPageStatus( $formattedPageStatus ); |
| 257 |
if ( !in_array( $this->pageStatus, $formattedPageStatus ) ) { |
| 258 |
throw new UnexpectedValueException( 'Not a valid page status!' ); |
| 259 |
} |
| 260 |
|
| 261 |
$userTalkId = false; |
| 262 |
|
| 263 |
if ( !$minorEdit || |
| 264 |
( $config->get( MainConfigNames::EnotifMinorEdits ) && |
| 265 |
!$editor->isAllowed( 'nominornewtalk' ) ) |
| 266 |
) { |
| 267 |
if ( $config->get( MainConfigNames::EnotifUserTalk ) |
| 268 |
&& $title->getNamespace() === NS_USER_TALK |
| 269 |
&& $this->canSendUserTalkEmail( $editor->getUser(), $title, $minorEdit ) |
| 270 |
) { |
| 271 |
$targetUser = User::newFromName( $title->getText() ); |
| 272 |
$this->compose( $targetUser, self::USER_TALK, $messageCache ); |
| 273 |
$userTalkId = $targetUser->getId(); |
| 274 |
} |
| 275 |
|
| 276 |
if ( $config->get( MainConfigNames::EnotifWatchlist ) ) { |
| 277 |
$userOptionsLookup = $mwServices->getUserOptionsLookup(); |
| 278 |
|
| 279 |
|
| 280 |
$userArray = UserArray::newFromIDs( $watchers ); |
| 281 |
foreach ( $userArray as $watchingUser ) { |
| 282 |
if ( $userOptionsLookup->getOption( $watchingUser, 'enotifwatchlistpages' ) |
| 283 |
&& ( !$minorEdit || $userOptionsLookup->getOption( $watchingUser, 'enotifminoredits' ) ) |
| 284 |
&& $watchingUser->isEmailConfirmed() |
| 285 |
&& $watchingUser->getId() != $userTalkId |
| 286 |
&& !in_array( $watchingUser->getName(), |
| 287 |
$config->get( MainConfigNames::UsersNotifiedOnAllChanges ) ) |
| 288 |
|
| 289 |
|
| 290 |
&& !( $config->get( MainConfigNames::BlockDisablesLogin ) && |
| 291 |
$watchingUser->getBlock() ) |
| 292 |
&& $hookRunner->onSendWatchlistEmailNotification( $watchingUser, $title, $this ) |
| 293 |
) { |
| 294 |
$this->compose( $watchingUser, self::WATCHLIST, $messageCache ); |
| 295 |
} |
| 296 |
} |
| 297 |
} |
| 298 |
} |
| 299 |
|
| 300 |
foreach ( $config->get( MainConfigNames::UsersNotifiedOnAllChanges ) as $name ) { |
| 301 |
if ( $editor->getUser()->getName() == $name ) { |
| 302 |
|
| 303 |
continue; |
| 304 |
} |
| 305 |
$user = User::newFromName( $name ); |
| 306 |
if ( $user instanceof User ) { |
| 307 |
$this->compose( $user, self::ALL_CHANGES, $messageCache ); |
| 308 |
} |
| 309 |
} |
| 310 |
$this->sendMails(); |
| 311 |
} |
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
private function canSendUserTalkEmail( UserIdentity $editor, $title, $minorEdit ) { |
| 320 |
$services = MediaWikiServices::getInstance(); |
| 321 |
$config = $services->getMainConfig(); |
| 322 |
|
| 323 |
if ( !$config->get( MainConfigNames::EnotifUserTalk ) || $title->getNamespace() !== NS_USER_TALK ) { |
| 324 |
return false; |
| 325 |
} |
| 326 |
|
| 327 |
$userOptionsLookup = $services->getUserOptionsLookup(); |
| 328 |
$targetUser = User::newFromName( $title->getText() ); |
| 329 |
|
| 330 |
if ( !$targetUser || $targetUser->isAnon() ) { |
| 331 |
wfDebug( __METHOD__ . ": user talk page edited, but user does not exist" ); |
| 332 |
} elseif ( $targetUser->getId() == $editor->getId() ) { |
| 333 |
wfDebug( __METHOD__ . ": user edited their own talk page, no notification sent" ); |
| 334 |
} elseif ( $targetUser->isTemp() ) { |
| 335 |
wfDebug( __METHOD__ . ": talk page owner is a temporary user so doesn't have email" ); |
| 336 |
} elseif ( $config->get( MainConfigNames::BlockDisablesLogin ) && |
| 337 |
$targetUser->getBlock() |
| 338 |
) { |
| 339 |
|
| 340 |
|
| 341 |
wfDebug( __METHOD__ . ": talk page owner is blocked and cannot login, no notification sent" ); |
| 342 |
} elseif ( $userOptionsLookup->getOption( $targetUser, 'enotifusertalkpages' ) |
| 343 |
&& ( !$minorEdit || $userOptionsLookup->getOption( $targetUser, 'enotifminoredits' ) ) |
| 344 |
) { |
| 345 |
if ( !$targetUser->isEmailConfirmed() ) { |
| 346 |
wfDebug( __METHOD__ . ": talk page owner doesn't have validated email" ); |
| 347 |
} elseif ( !( new HookRunner( $services->getHookContainer() ) ) |
| 348 |
->onAbortTalkPageEmailNotification( $targetUser, $title ) |
| 349 |
) { |
| 350 |
wfDebug( __METHOD__ . ": talk page update notification is aborted for this user" ); |
| 351 |
} else { |
| 352 |
wfDebug( __METHOD__ . ": sending talk page update notification" ); |
| 353 |
return true; |
| 354 |
} |
| 355 |
} else { |
| 356 |
wfDebug( __METHOD__ . ": talk page owner doesn't want notifications" ); |
| 357 |
} |
| 358 |
return false; |
| 359 |
} |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
private function composeCommonMailtext( MessageCache $messageCache ) { |
| 366 |
$services = MediaWikiServices::getInstance(); |
| 367 |
$config = $services->getMainConfig(); |
| 368 |
$userOptionsLookup = $services->getUserOptionsLookup(); |
| 369 |
$urlUtils = $services->getUrlUtils(); |
| 370 |
|
| 371 |
$this->composed_common = true; |
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
$keys = []; |
| 378 |
$postTransformKeys = []; |
| 379 |
$pageTitleUrl = $this->title->getCanonicalURL(); |
| 380 |
$pageTitle = $this->title->getPrefixedText(); |
| 381 |
|
| 382 |
if ( $this->oldid ) { |
| 383 |
|
| 384 |
$keys['$NEWPAGE'] = "\n\n" . wfMessage( |
| 385 |
'enotif_lastdiff', |
| 386 |
$this->title->getCanonicalURL( [ 'diff' => 'next', 'oldid' => $this->oldid ] ) |
| 387 |
)->inContentLanguage()->text(); |
| 388 |
|
| 389 |
if ( !$config->get( MainConfigNames::EnotifImpersonal ) ) { |
| 390 |
|
| 391 |
|
| 392 |
$keys['$NEWPAGE'] .= "\n\n" . wfMessage( |
| 393 |
'enotif_lastvisited', |
| 394 |
$this->title->getCanonicalURL( [ 'diff' => '0', 'oldid' => $this->oldid ] ) |
| 395 |
)->inContentLanguage()->text(); |
| 396 |
} |
| 397 |
$keys['$OLDID'] = $this->oldid; |
| 398 |
$keys['$PAGELOG'] = ''; |
| 399 |
} else { |
| 400 |
|
| 401 |
$keys['$OLDID'] = ''; |
| 402 |
$keys['$NEWPAGE'] = ''; |
| 403 |
$keys['$PAGELOG'] = "\n\n" . wfMessage( |
| 404 |
'enotif_pagelog', |
| 405 |
SpecialPage::getTitleFor( 'Log' )->getCanonicalURL( [ 'page' => $this->title->getPrefixedDBkey() ] ) |
| 406 |
)->inContentLanguage()->text(); |
| 407 |
|
| 408 |
} |
| 409 |
|
| 410 |
$keys['$PAGETITLE'] = $this->title->getPrefixedText(); |
| 411 |
$keys['$PAGETITLE_URL'] = $this->title->getCanonicalURL(); |
| 412 |
$keys['$PAGEMINOREDIT'] = $this->minorEdit ? |
| 413 |
"\n\n" . wfMessage( 'enotif_minoredit' )->inContentLanguage()->text() : |
| 414 |
''; |
| 415 |
$keys['$UNWATCHURL'] = $this->title->getCanonicalURL( 'action=unwatch' ); |
| 416 |
|
| 417 |
if ( $this->editor->isAnon() ) { |
| 418 |
|
| 419 |
$keys['$PAGEEDITOR'] = wfMessage( 'enotif_anon_editor', $this->editor->getName() ) |
| 420 |
->inContentLanguage()->text(); |
| 421 |
$keys['$PAGEEDITOR_EMAIL'] = wfMessage( 'noemailtitle' )->inContentLanguage()->text(); |
| 422 |
} elseif ( $this->editor->isTemp() ) { |
| 423 |
$keys['$PAGEEDITOR'] = wfMessage( 'enotif_temp_editor', $this->editor->getName() ) |
| 424 |
->inContentLanguage()->text(); |
| 425 |
$keys['$PAGEEDITOR_EMAIL'] = wfMessage( 'noemailtitle' )->inContentLanguage()->text(); |
| 426 |
} else { |
| 427 |
$keys['$PAGEEDITOR'] = $config->get( MainConfigNames::EnotifUseRealName ) && |
| 428 |
$this->editor->getRealName() !== '' |
| 429 |
? $this->editor->getRealName() : $this->editor->getName(); |
| 430 |
$emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $this->editor->getName() ); |
| 431 |
$keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalURL(); |
| 432 |
} |
| 433 |
|
| 434 |
$keys['$PAGEEDITOR_WIKI'] = $this->editor->getTalkPage()->getCanonicalURL(); |
| 435 |
$keys['$HELPPAGE'] = $urlUtils->expand( |
| 436 |
Skin::makeInternalOrExternalUrl( wfMessage( 'helppage' )->inContentLanguage()->text() ), |
| 437 |
PROTO_CURRENT |
| 438 |
) ?? false; |
| 439 |
|
| 440 |
|
| 441 |
$postTransformKeys['$PAGESUMMARY'] = $this->summary == '' ? ' - ' : $this->summary; |
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
$this->subject = wfMessage( 'enotif_subject_' . $this->pageStatus )->inContentLanguage() |
| 449 |
->params( $pageTitle, $keys['$PAGEEDITOR'] )->text(); |
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
$keys['$PAGEINTRO'] = wfMessage( 'enotif_body_intro_' . $this->pageStatus ) |
| 455 |
->inContentLanguage() |
| 456 |
->params( $pageTitle, $keys['$PAGEEDITOR'], "<{$pageTitleUrl}>" ) |
| 457 |
->text(); |
| 458 |
|
| 459 |
$body = wfMessage( 'enotif_body' )->inContentLanguage()->plain(); |
| 460 |
$body = strtr( $body, $keys ); |
| 461 |
$body = $messageCache->transform( $body, false, null, $this->title ); |
| 462 |
$this->body = wordwrap( strtr( $body, $postTransformKeys ), 72 ); |
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
$adminAddress = new MailAddress( |
| 468 |
$config->get( MainConfigNames::PasswordSender ), |
| 469 |
wfMessage( 'emailsender' )->inContentLanguage()->text() |
| 470 |
); |
| 471 |
if ( $config->get( MainConfigNames::EnotifRevealEditorAddress ) |
| 472 |
&& ( $this->editor->getEmail() != '' ) |
| 473 |
&& $userOptionsLookup->getOption( $this->editor, 'enotifrevealaddr' ) |
| 474 |
) { |
| 475 |
$editorAddress = MailAddress::newFromUser( $this->editor ); |
| 476 |
if ( $config->get( MainConfigNames::EnotifFromEditor ) ) { |
| 477 |
$this->from = $editorAddress; |
| 478 |
} else { |
| 479 |
$this->from = $adminAddress; |
| 480 |
$this->replyto = $editorAddress; |
| 481 |
} |
| 482 |
} else { |
| 483 |
$this->from = $adminAddress; |
| 484 |
$this->replyto = new MailAddress( |
| 485 |
$config->get( MainConfigNames::NoReplyAddress ) |
| 486 |
); |
| 487 |
} |
| 488 |
} |
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
private function compose( UserEmailContact $user, $source, MessageCache $messageCache ) { |
| 500 |
if ( !$this->composed_common ) { |
| 501 |
$this->composeCommonMailtext( $messageCache ); |
| 502 |
} |
| 503 |
|
| 504 |
if ( MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::EnotifImpersonal ) ) { |
| 505 |
$this->mailTargets[] = MailAddress::newFromUser( $user ); |
| 506 |
} else { |
| 507 |
$this->sendPersonalised( $user, $source ); |
| 508 |
} |
| 509 |
} |
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
private function sendMails() { |
| 515 |
if ( MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::EnotifImpersonal ) ) { |
| 516 |
$this->sendImpersonal( $this->mailTargets ); |
| 517 |
} |
| 518 |
} |
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
private function sendPersonalised( UserEmailContact $watchingUser, $source ): StatusValue { |
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
$to = MailAddress::newFromUser( $watchingUser ); |
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
$mwServices = MediaWikiServices::getInstance(); |
| 541 |
$contLang = $mwServices->getContentLanguage(); |
| 542 |
$watchingUserName = ( |
| 543 |
$mwServices->getMainConfig()->get( MainConfigNames::EnotifUseRealName ) && |
| 544 |
$watchingUser->getRealName() !== '' |
| 545 |
) ? $watchingUser->getRealName() : $watchingUser->getUser()->getName(); |
| 546 |
$body = str_replace( |
| 547 |
[ |
| 548 |
'$WATCHINGUSERNAME', |
| 549 |
'$PAGEEDITDATE', |
| 550 |
'$PAGEEDITTIME' |
| 551 |
], |
| 552 |
[ |
| 553 |
$watchingUserName, |
| 554 |
$contLang->userDate( $this->timestamp, $watchingUser->getUser() ), |
| 555 |
$contLang->userTime( $this->timestamp, $watchingUser->getUser() ) |
| 556 |
], |
| 557 |
$this->body |
| 558 |
); |
| 559 |
|
| 560 |
$headers = []; |
| 561 |
if ( $source === self::WATCHLIST ) { |
| 562 |
$headers['List-Help'] = 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Watchlist'; |
| 563 |
} |
| 564 |
|
| 565 |
return $mwServices |
| 566 |
->getEmailer() |
| 567 |
->send( |
| 568 |
[ $to ], |
| 569 |
$this->from, |
| 570 |
$this->subject, |
| 571 |
$body, |
| 572 |
null, |
| 573 |
[ |
| 574 |
'replyTo' => $this->replyto, |
| 575 |
'headers' => $headers, |
| 576 |
] |
| 577 |
); |
| 578 |
} |
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
private function sendImpersonal( array $addresses ): ?StatusValue { |
| 587 |
if ( count( $addresses ) === 0 ) { |
| 588 |
return null; |
| 589 |
} |
| 590 |
$services = MediaWikiServices::getInstance(); |
| 591 |
$contLang = $services->getContentLanguage(); |
| 592 |
$body = str_replace( |
| 593 |
[ |
| 594 |
'$WATCHINGUSERNAME', |
| 595 |
'$PAGEEDITDATE', |
| 596 |
'$PAGEEDITTIME' |
| 597 |
], |
| 598 |
[ |
| 599 |
wfMessage( 'enotif_impersonal_salutation' )->inContentLanguage()->text(), |
| 600 |
$contLang->date( $this->timestamp, false, false ), |
| 601 |
$contLang->time( $this->timestamp, false, false ) |
| 602 |
], |
| 603 |
$this->body |
| 604 |
); |
| 605 |
|
| 606 |
return $services |
| 607 |
->getEmailer() |
| 608 |
->send( |
| 609 |
$addresses, |
| 610 |
$this->from, |
| 611 |
$this->subject, |
| 612 |
$body, |
| 613 |
null, |
| 614 |
[ |
| 615 |
'replyTo' => $this->replyto, |
| 616 |
] |
| 617 |
); |
| 618 |
} |
| 619 |
|
| 620 |
} |