90 private Config $mainConfig;
104 $this->editor = $services->getUserFactory()->newFromAuthority(
$editor );
106 $this->oldid = $recentChange->
getAttribute(
'rc_last_oldid' );
107 $this->minorEdit = $recentChange->
getAttribute(
'rc_minor' );
108 $this->timestamp = $recentChange->
getAttribute(
'rc_timestamp' );
109 $this->summary = $recentChange->
getAttribute(
'rc_comment' );
113 $this->mainConfig = $services->getMainConfig();
114 $this->userOptionsLookup = $services->getUserOptionsLookup();
115 $this->urlUtils = $services->getUrlUtils();
116 $this->messageParser = $services->getMessageParser();
117 $this->contentLanguage = $services->getContentLanguage();
118 $this->emailer = $services->getEmailer();
124 private function composeCommonMailtext() {
125 $this->composed_common =
true;
127 # You as the WikiAdmin and Sysops can make use of plenty of
128 # named variables when composing your notification emails while
129 # simply editing the Meta pages
132 $postTransformKeys = [];
133 $pageTitleUrl = $this->title->getCanonicalURL();
134 $pageTitle = $this->title->getPrefixedText();
136 if ( $this->oldid ) {
140 $this->title->getCanonicalURL( [
'diff' =>
'next',
'oldid' => $this->oldid ] )
141 )->inContentLanguage()->text();
147 'enotif_lastvisited',
148 $this->title->getCanonicalURL( [
'diff' =>
'0',
'oldid' => $this->oldid ] )
149 )->inContentLanguage()->text();
152 $keys[
'$PAGELOG'] =
'';
155 $keys[
'$OLDID'] =
'';
156 $keys[
'$NEWPAGE'] =
'';
160 $this->title->getPrefixedDBkey() ] )
161 )->inContentLanguage()->text();
164 $keys[
'$PAGETITLE'] = $this->title->getPrefixedText();
165 $keys[
'$PAGETITLE_URL'] = $this->title->getCanonicalURL();
166 $keys[
'$PAGEMINOREDIT'] = $this->minorEdit ?
167 "\n\n" .
wfMessage(
'enotif_minoredit' )->inContentLanguage()->text() :
169 $keys[
'$UNWATCHURL'] = $this->title->getCanonicalURL(
'action=unwatch' );
171 if ( $this->editor->isAnon() ) {
172 # real anon (user:xxx.xxx.xxx.xxx)
173 $keys[
'$PAGEEDITOR'] =
wfMessage(
'enotif_anon_editor', $this->editor->getName() )
174 ->inContentLanguage()->text();
175 $keys[
'$PAGEEDITOR_EMAIL'] =
wfMessage(
'noemailtitle' )->inContentLanguage()->text();
176 } elseif ( $this->editor->isTemp() ) {
177 $keys[
'$PAGEEDITOR'] =
wfMessage(
'enotif_temp_editor', $this->editor->getName() )
178 ->inContentLanguage()->text();
179 $keys[
'$PAGEEDITOR_EMAIL'] =
wfMessage(
'noemailtitle' )->inContentLanguage()->text();
182 $this->editor->getRealName() !==
''
183 ? $this->editor->getRealName() : $this->editor->getName();
185 $keys[
'$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalURL();
188 $keys[
'$PAGEEDITOR_WIKI'] = $this->editor->getTalkPage()->getCanonicalURL();
189 $keys[
'$HELPPAGE'] = $this->urlUtils->expand(
190 Skin::makeInternalOrExternalUrl(
wfMessage(
'helppage' )->inContentLanguage()->text() ),
194 # Replace this after transforming the message, T37019
195 $postTransformKeys[
'$PAGESUMMARY'] = $this->summary ==
'' ?
' - ' :
$this->summary;
202 $this->subject =
wfMessage(
'enotif_subject_' . $this->pageStatus )->inContentLanguage()
203 ->params( $pageTitle, $keys[
'$PAGEEDITOR'] )->text();
208 $keys[
'$PAGEINTRO'] =
wfMessage(
'enotif_body_intro_' . $this->pageStatus )
209 ->inContentLanguage()
210 ->params( $pageTitle, $keys[
'$PAGEEDITOR'],
"<{$pageTitleUrl}>" )
215 $body = $this->messageParser->transform(
$body,
false,
null, $this->title );
216 $this->body = wordwrap( strtr(
$body, $postTransformKeys ), 72 );
218 # Reveal the page editor's address as REPLY-TO address only if
219 # the user has not opted-out and the option is enabled at the
220 # global configuration level.
223 wfMessage(
'emailsender' )->inContentLanguage()->text()
226 && ( $this->editor->getEmail() !=
'' )
227 && $this->userOptionsLookup->getOption( $this->editor,
'enotifrevealaddr' )
231 $this->from = $editorAddress;
233 $this->from = $adminAddress;
234 $this->replyto = $editorAddress;
237 $this->from = $adminAddress;
253 if ( !$this->composed_common ) {
254 $this->composeCommonMailtext();
258 wfDeprecated(
'EnotifImpersonal is now deprecated',
'1.44' );
260 $this->mailTargets[] = MailAddress::newFromUser( $user );
262 $this->sendPersonalised( $user,
$source );
271 wfDeprecated(
'EnotifImpersonal is now deprecated',
'1.44' );
272 $this->sendImpersonal( $this->mailTargets );
293 # $PAGEEDITDATE is the time and date of the page change
294 # expressed in terms of individual local time of the notification
295 # recipient, i.e. watching user
296 $watchingUserName = (
308 $this->contentLanguage->userDate( $this->timestamp, $watchingUser->
getUser() ),
309 $this->contentLanguage->userTime( $this->timestamp, $watchingUser->
getUser() )
315 if (
$source === self::WATCHLIST ) {
316 $headers[
'List-Help'] =
'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Watchlist';
319 return $this->emailer->send(
326 'replyTo' => $this->replyto,
327 'headers' => $headers,
338 private function sendImpersonal( array $addresses ): ?
StatusValue {
339 if ( count( $addresses ) === 0 ) {
343 $contLang = $services->getContentLanguage();
351 wfMessage(
'enotif_impersonal_salutation' )->inContentLanguage()->text(),
352 $contLang->date( $this->timestamp,
false,
false ),
353 $contLang->time( $this->timestamp,
false,
false )
367 'replyTo' => $this->replyto,