74 private Config $mainConfig;
88 $this->editor = $services->getUserFactory()->newFromAuthority(
$editor );
90 $this->oldid = $recentChange->
getAttribute(
'rc_last_oldid' );
91 $this->minorEdit = $recentChange->
getAttribute(
'rc_minor' );
92 $this->timestamp = $recentChange->
getAttribute(
'rc_timestamp' );
93 $this->summary = $recentChange->
getAttribute(
'rc_comment' );
97 $this->mainConfig = $services->getMainConfig();
98 $this->userOptionsLookup = $services->getUserOptionsLookup();
99 $this->urlUtils = $services->getUrlUtils();
100 $this->messageParser = $services->getMessageParser();
101 $this->contentLanguage = $services->getContentLanguage();
102 $this->emailer = $services->getEmailer();
108 private function composeCommonMailtext() {
109 $this->composed_common =
true;
111 # You as the WikiAdmin and Sysops can make use of plenty of
112 # named variables when composing your notification emails while
113 # simply editing the Meta pages
116 $postTransformKeys = [];
117 $pageTitleUrl = $this->title->getCanonicalURL();
118 $pageTitle = $this->title->getPrefixedText();
120 if ( $this->oldid ) {
124 $this->title->getCanonicalURL( [
'diff' =>
'next',
'oldid' => $this->oldid ] )
125 )->inContentLanguage()->text();
130 'enotif_lastvisited',
131 $this->title->getCanonicalURL( [
'diff' =>
'0',
'oldid' => $this->oldid ] )
132 )->inContentLanguage()->text();
134 $keys[
'$PAGELOG'] =
'';
137 $keys[
'$OLDID'] =
'';
138 $keys[
'$NEWPAGE'] =
'';
142 $this->title->getPrefixedDBkey() ] )
143 )->inContentLanguage()->text();
146 $keys[
'$PAGETITLE'] = $this->title->getPrefixedText();
147 $keys[
'$PAGETITLE_URL'] = $this->title->getCanonicalURL();
148 $keys[
'$PAGEMINOREDIT'] = $this->minorEdit ?
149 "\n\n" .
wfMessage(
'enotif_minoredit' )->inContentLanguage()->text() :
151 $keys[
'$UNWATCHURL'] = $this->title->getCanonicalURL(
'action=unwatch' );
153 if ( $this->editor->isAnon() ) {
154 # real anon (user:xxx.xxx.xxx.xxx)
155 $keys[
'$PAGEEDITOR'] =
wfMessage(
'enotif_anon_editor', $this->editor->getName() )
156 ->inContentLanguage()->text();
157 $keys[
'$PAGEEDITOR_EMAIL'] =
wfMessage(
'noemailtitle' )->inContentLanguage()->text();
158 } elseif ( $this->editor->isTemp() ) {
159 $keys[
'$PAGEEDITOR'] =
wfMessage(
'enotif_temp_editor', $this->editor->getName() )
160 ->inContentLanguage()->text();
161 $keys[
'$PAGEEDITOR_EMAIL'] =
wfMessage(
'noemailtitle' )->inContentLanguage()->text();
164 $this->editor->getRealName() !==
''
165 ? $this->editor->getRealName() : $this->editor->getName();
167 $keys[
'$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalURL();
170 $keys[
'$PAGEEDITOR_WIKI'] = $this->editor->getTalkPage()->getCanonicalURL();
171 $keys[
'$HELPPAGE'] = $this->urlUtils->expand(
172 Skin::makeInternalOrExternalUrl(
wfMessage(
'helppage' )->inContentLanguage()->text() ),
176 # Replace this after transforming the message, T37019
177 $postTransformKeys[
'$PAGESUMMARY'] = $this->summary ==
'' ?
' - ' :
$this->summary;
184 $this->subject =
wfMessage(
'enotif_subject_' . $this->pageStatus )->inContentLanguage()
185 ->params( $pageTitle, $keys[
'$PAGEEDITOR'] )->text();
190 $keys[
'$PAGEINTRO'] =
wfMessage(
'enotif_body_intro_' . $this->pageStatus )
191 ->inContentLanguage()
192 ->params( $pageTitle, $keys[
'$PAGEEDITOR'],
"<{$pageTitleUrl}>" )
197 $body = $this->messageParser->transform(
$body,
false,
null, $this->title );
198 $this->body = wordwrap( strtr(
$body, $postTransformKeys ), 72 );
200 # Reveal the page editor's address as REPLY-TO address only if
201 # the user has not opted-out and the option is enabled at the
202 # global configuration level.
203 $adminAddress =
new MailAddress(
205 wfMessage(
'emailsender' )->inContentLanguage()->text()
208 && ( $this->editor->getEmail() !=
'' )
209 && $this->userOptionsLookup->getOption( $this->editor,
'enotifrevealaddr' )
211 $editorAddress = MailAddress::newFromUser( $this->editor );
213 $this->from = $editorAddress;
215 $this->from = $adminAddress;
216 $this->replyto = $editorAddress;
219 $this->from = $adminAddress;
220 $this->replyto =
new MailAddress(
233 if ( !$this->composed_common ) {
234 $this->composeCommonMailtext();
241 $to = MailAddress::newFromUser( $watchingUser );
243 # $PAGEEDITDATE is the time and date of the page change
244 # expressed in terms of individual local time of the notification
245 # recipient, i.e. watching user
246 $watchingUserName = (
258 $this->contentLanguage->userDate( $this->timestamp, $watchingUser->
getUser() ),
259 $this->contentLanguage->userTime( $this->timestamp, $watchingUser->
getUser() )
265 if (
$source === self::WATCHLIST ) {
266 $headers[
'List-Help'] =
'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Watchlist';
269 $this->emailer->send(
276 'replyTo' => $this->replyto,
277 'headers' => $headers,