Merge "Specify that watchlist emails are only sent once per page"

This commit is contained in:
jenkins-bot 2021-12-14 18:48:22 +00:00 committed by Gerrit Code Review
commit 194b946b38
6 changed files with 16 additions and 5 deletions

View file

@ -197,6 +197,7 @@
"notification-header-watchlist-multiuser-deleted": "<strong>$1</strong>, a page on {{GENDER:$2|your}} watchlist, was deleted $3 {{PLURAL:$3|time|times}}.",
"notification-header-watchlist-multiuser-moved": "<strong>$1</strong>, a page on {{GENDER:$2|your}} watchlist, was moved $3 {{PLURAL:$3|time|times}}.",
"notification-header-watchlist-multiuser-restored": "<strong>$1</strong>, a page on {{GENDER:$2|your}} watchlist, was restored $3 {{PLURAL:$3|time|times}}.",
"notification-body-watchlist-once": "There will be no other email notifications in case of further activity unless {{GENDER:$1|you visit}} this page while logged in.",
"notification-welcome-link": "",
"notification-welcome-linktext": "Welcome",
"notification-header-thank-you-1-edit": "{{GENDER:$2|You}} just made {{GENDER:$2|your}} first edit; thank {{GENDER:$2|you}}, and welcome!",

View file

@ -200,6 +200,7 @@
"notification-header-watchlist-multiuser-deleted": "Text of a notification when multiple different users delete pages on your watchlist.\n* $1 - name of the page that was deleted (with namespace) \n* $2 - name of the user viewing the notification, can be used for GENDER \n* $3 - Number of times the page has been deleted. (Always greater than one)",
"notification-header-watchlist-multiuser-moved": "Text of a notification when multiple different users move pages on your watchlist.\n* $1 - name of the page that was moved (with namespace) \n* $2 - name of the user viewing the notification, can be used for GENDER \n* $3 - Number of times the page has been moved. (Always greater than one)",
"notification-header-watchlist-multiuser-restored": "Text of a notification when multiple different users restore pages on your watchlist.\n* $1 - name of the page that was restored (with namespace) \n* $2 - name of the user viewing the notification, can be used for GENDER \n* $3 - Number of times the page has been restored. (Always greater than one)",
"notification-body-watchlist-once": "Text added to email notifications of watchlist changes to specify that no further emails will be sent for that page until it is visited. \n* $1 - user's name for use in GENDER",
"notification-welcome-link": "{{notranslate}}",
"notification-welcome-linktext": "Link text for link to the wiki's welcome or introduction page.\n{{Identical|Welcome}}",
"notification-header-thank-you-1-edit": "Text of the editor welcome notification for their first edit.\nParameters:\n* $1 - the formatted username of the new user\n* $2 - the username for gender purposes",

View file

@ -1650,7 +1650,8 @@ class EchoHooks implements RecentChange_saveHook {
'revid' => $change->getAttribute( "rc_this_oldid" ),
'logid' => $change->getAttribute( "rc_logid" ),
'status' => $change->mExtra["pageStatus"],
'timestamp' => $change->getAttribute( "rc_timestamp" )
'timestamp' => $change->getAttribute( "rc_timestamp" ),
'emailonce' => $this->config->get( 'EchoWatchlistEmailOncePerPage' )
],
'agent' => $user
] );

View file

@ -122,14 +122,14 @@ class EchoNotifier {
$userOptionsLookup = MediaWikiServices::getInstance()->getUserOptionsLookup();
$lang = Language::factory( $userOptionsLookup->getOption( $user, 'language' ) );
$formatter = new EchoPlainTextEmailFormatter( $user, $lang );
$content = $formatter->format( $event );
$content = $formatter->format( $event, 'email' );
if ( !$content ) {
return false;
}
if ( $emailFormat === EchoEmailFormat::HTML ) {
$htmlEmailFormatter = new EchoHtmlEmailFormatter( $user, $lang );
$htmlContent = $htmlEmailFormatter->format( $event );
$htmlContent = $htmlEmailFormatter->format( $event, 'email' );
$multipartBody = [
'text' => $content['body'],
'html' => $htmlContent['body']

View file

@ -45,9 +45,10 @@ abstract class EchoEventFormatter {
/**
* @param EchoEvent $event
* @param string $distributionType 'web' or 'email'
* @return string[]|string|false Output format depends on implementation, false if it cannot be formatted
*/
final public function format( EchoEvent $event ) {
final public function format( EchoEvent $event, string $distributionType = "web" ) {
// Deleted events should have been filtered out before getting there.
// This is just to be sure.
if ( $event->isDeleted() ) {
@ -64,7 +65,7 @@ abstract class EchoEventFormatter {
return false;
}
$model = EchoEventPresentationModel::factory( $event, $this->language, $this->user );
$model = EchoEventPresentationModel::factory( $event, $this->language, $this->user, $distributionType );
if ( !$model->canRender() ) {
return false;
}

View file

@ -68,6 +68,13 @@ class EchoWatchlistChangePresentationModel extends EchoEventPresentationModel {
}
}
public function getBodyMessage() {
if ( $this->event->getExtraParam( 'emailonce' ) && $this->getDistributionType() == 'email' ) {
return $this->msg( 'notification-body-watchlist-once', $this->getViewingUserForGender() );
}
return false;
}
private function isMultiUserBundle() {
foreach ( $this->getBundledEvents() as $bundled ) {
if ( !$bundled->getAgent()->equals( $this->event->getAgent() ) ) {