Add email body preview to emailuser notification

when the subject line is left with the default
generated value, we take the begining of the
email content to add a preview in the
notification.

Bug: T121831
Change-Id: Ib7c646f6709c7100ef51186f84fe14807d6a211a
This commit is contained in:
Stephane Bisson 2016-02-10 17:09:41 -05:00
parent 9c7c869a29
commit 09928f1ed2
4 changed files with 14 additions and 5 deletions

View file

@ -1050,6 +1050,8 @@ class EchoHooks {
* @return bool true in all cases
*/
public static function onEmailUserComplete( $address, $from, $subject, $text ) {
global $wgContLang;
if ( $from->name === $address->name ) {
// nothing to notify
return true;
@ -1057,11 +1059,18 @@ class EchoHooks {
$userTo = User::newFromName( $address->name );
$userFrom = User::newFromName( $from->name );
$autoSubject = wfMessage( 'defemailsubject', $from->name )->inContentLanguage()->text();
if ( $subject === $autoSubject ) {
$preview = $wgContLang->truncate( $text, 125 );
} else {
$preview = $subject;
}
EchoEvent::create( array(
'type' => 'emailuser',
'extra' => array(
'to-user-id' => $userTo->getId(),
'subject' => $subject,
'preview' => $preview,
),
'agent' => $userFrom,
) );

View file

@ -107,7 +107,7 @@
"notification-body-reverted": "$1",
"notification-emailuser": "[[User:$1|$1]] {{GENDER:$1|sent}} you an email.",
"notification-header-emailuser": "$1 {{GENDER:$2|sent}} you an email.",
"notification-body-email-user": "$1",
"notification-body-emailuser": "$1",
"notification-edit-talk-page-email-subject2": "$1 {{GENDER:$1|left}} you a message on {{SITENAME}}",
"notification-edit-talk-page-email-batch-body2": "$1 {{GENDER:$1|left}} a message on your talk page.",
"notification-edit-talk-page-email-batch-body-with-section": "$1 {{GENDER:$1|left}} a message on your talk page in \"$2\".",

View file

@ -128,7 +128,7 @@
"notification-body-reverted": "{{notranslate}}",
"notification-emailuser": "Format for displaying notifications of a user has sent an email to another user. Parameters:\n* $1 - the username of the person the email, plain text. Can be used for GENDER.",
"notification-header-emailuser": "Flyout-specific format for displaying notifications of user has sent an email to another user.\n\nParameters:\n* $1 - the formatted username of the person who sent the email.\n* $2 - the username for GENDER.",
"notification-body-email-user": "{{notranslate}}",
"notification-body-emailuser": "{{notranslate}}",
"notification-edit-talk-page-email-subject2": "Email subject. Parameters:\n* $1 - a username which can be used for gender support",
"notification-edit-talk-page-email-batch-body2": "First line of the email notification for a talk page edit. The following line completes it with the description of the message in question, that is its edit summary.\n\nParameters:\n* $1 - a username (which also links to the userpage of the user in question, in the HTML version)\nSee also:\n* {{msg-mw|Notification-edit-talk-page2}}\n* {{msg-mw|Notification-edit-talk-page-email-subject2}}\n* {{msg-mw|Notification-edit-talk-page-flyout2}}",
"notification-edit-talk-page-email-batch-body-with-section": "Email notification for talk page edit with new section or new comment. Parameters:\n* $1 - a username\n* $2 - the raw section title text",

View file

@ -15,7 +15,7 @@ class EchoEmailUserPresentationModel extends EchoEventPresentationModel {
}
public function getBodyMessage() {
$subject = $this->event->getExtraParam( 'subject' );
return $subject ? $this->msg( 'notification-body-email-user' )->plaintextParams( $subject ) : false;
$preview = $this->event->getExtraParam( 'preview' );
return $preview ? $this->msg( 'notification-body-emailuser' )->plaintextParams( $preview ) : false;
}
}