jenkins-bot has submitted this change and it was merged.
Change subject: Add plain text email formatter
......................................................................
Add plain text email formatter
Formatters based on presentation models for
individual event emails and digest (daily, weekly)
plain text emails.
Bug: T121067
Change-Id: I4eceaf521315adab7429a8a73ffca70ebcddab86
---
M autoload.php
M i18n/en.json
M i18n/qqq.json
M includes/DiscussionParser.php
M includes/EmailBatch.php
M includes/Notifier.php
A includes/formatters/EchoEventDigestFormatter.php
M includes/formatters/EchoEventFormatter.php
A includes/formatters/EchoPlainTextDigestEmailFormatter.php
A includes/formatters/EchoPlainTextEmailFormatter.php
M includes/formatters/EventPresentationModel.php
M includes/mapper/EventMapper.php
12 files changed, 354 insertions(+), 57 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/autoload.php b/autoload.php
index 263f893..2d5f7ab 100644
--- a/autoload.php
+++ b/autoload.php
@@ -43,6 +43,7 @@
'EchoEmailSingle' => __DIR__ . '/includes/EmailFormatter.php',
'EchoEmailUserPresentationModel' => __DIR__ .
'/includes/formatters/EmailUserPresentationModel.php',
'EchoEvent' => __DIR__ . '/includes/model/Event.php',
+ 'EchoEventDigestFormatter' => __DIR__ .
'/includes/formatters/EchoEventDigestFormatter.php',
'EchoEventFormatter' => __DIR__ .
'/includes/formatters/EchoEventFormatter.php',
'EchoEventMapper' => __DIR__ . '/includes/mapper/EventMapper.php',
'EchoEventMapperTest' => __DIR__ .
'/tests/phpunit/mapper/EventMapperTest.php',
@@ -76,6 +77,8 @@
'EchoPageLinkFormatter' => __DIR__ .
'/includes/formatters/PageLinkFormatter.php',
'EchoPageLinkedPresentationModel' => __DIR__ .
'/includes/formatters/PageLinkedPresentationModel.php',
'EchoPresentationModelSectionTrait' => __DIR__ .
'/includes/formatters/PresentationModelSectionTrait.php',
+ 'EchoPlainTextDigestEmailFormatter' => __DIR__ .
'/includes/formatters/EchoPlainTextDigestEmailFormatter.php',
+ 'EchoPlainTextEmailFormatter' => __DIR__ .
'/includes/formatters/EchoPlainTextEmailFormatter.php',
'EchoRevertedPresentationModel' => __DIR__ .
'/includes/formatters/RevertedPresentationModel.php',
'EchoRevisionLocalCache' => __DIR__ .
'/includes/cache/RevisionLocalCache.php',
'EchoSeenTime' => __DIR__ . '/includes/SeenTime.php',
diff --git a/i18n/en.json b/i18n/en.json
index 06b8903..267c17b 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -190,7 +190,7 @@
"echo-email-subject-default": "New notification at {{SITENAME}}",
"echo-email-body-default": "You have a new notification at
{{SITENAME}}:\n\n$1",
"echo-email-batch-body-default": "You have a new notification.",
- "echo-email-footer-default": "$2\n\nTo control which emails we send
you, check your
preferences:\n{{canonicalurl:{{#special:Preferences}}#mw-prefsection-echo}}\n\n$1",
+ "echo-email-plain-footer": "To control which emails we send you, check
your preferences:",
"echo-email-footer-default-html": "To control which emails we send you,
<a href=\"$2\" style=\"text-decoration:none; color: #3868B0;\">check your
preferences</a>.<br />\n$1",
"echo-notification-alert": "{{PLURAL:$1|Alert ($1)|Alerts
($1)|100=Alerts (99+)}}",
"echo-notification-message": "{{PLURAL:$1|Message ($1)|Messages
($1)|100=Messages (99+)}}",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 955d3aa..95f595f 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -181,7 +181,7 @@
"echo-email-subject-default": "Default subject for Echo e-mail
notifications",
"echo-email-body-default": "Default message content for Echo email
notifications. Parameters:\n* $1 - a plain text description of the
notification",
"echo-email-batch-body-default": "Default message for Echo e-mail
digest notifications",
- "echo-email-footer-default": "Default footer content for Echo text
e-mail notifications. Parameters:\n* $1 - the address of the organization that
sent the email\n* $2 - \"-------...\"
({{msg-mw|echo-email-batch-separator}})\n\nFor HTML version, see
{{msg-mw|echo-email-footer-default-html}}.",
+ "echo-email-plain-footer": "Footer content for Echo text e-mail
notifications.\n\nFor HTML version, see
{{msg-mw|echo-email-footer-default-html}}.",
"echo-email-footer-default-html": "Default footer content for Echo html
e-mail notifications. Parameters:\n* $1 - the address of the organization that
sent the email\n* $2 - the URL to the notification preference page\nFor
plain-text version, see {{msg-mw|Echo-email-footer-default}}.",
"echo-notification-alert": "Label for alert notifications (= non
discussion notifications) tab in Echo overlay. Parameters:\n* $1 - the number
of unread alerts. The number cannot be higher than 100.\nSee also:\n*
{{msg-mw|Echo-notification-message}}\n{{Identical|Alert}}",
"echo-notification-message": "Label for message notifications (=
discussion notifications) tab in Echo overlay. Parameters:\n* $1 - the number
of unread messages. The number cannot be higher than 100.\nSee also:\n*
{{msg-mw|Echo-notification-alert}}\n{{Identical|Message}}",
diff --git a/includes/DiscussionParser.php b/includes/DiscussionParser.php
index e5ce8d9..909723b 100644
--- a/includes/DiscussionParser.php
+++ b/includes/DiscussionParser.php
@@ -835,8 +835,7 @@
static function getTextSnippet( $text, Language $lang, $length = 150 ) {
// Parse wikitext
$html = MessageCache::singleton()->parse( $text )->getText();
- // Remove HTML tags and decode HTML entities
- $plaintext = trim( html_entity_decode( strip_tags( $html ),
ENT_QUOTES ) );
+ $plaintext = self::htmlToText( $html );
return $lang->truncate( $plaintext, $length );
}
@@ -850,8 +849,15 @@
static function getTextSnippetFromSummary( $text, Language $lang,
$length = 150 ) {
// Parse wikitext with summary parser
$html = Linker::formatLinksInComment(
Sanitizer::escapeHtmlAllowEntities( $text ) );
- // Remove HTML tags and decode HTML entities
- $plaintext = trim( html_entity_decode( strip_tags( $html ),
ENT_QUOTES ) );
+ $plaintext = self::htmlToText( $html );
return $lang->truncate( $plaintext, $length );
}
+
+ /**
+ * @param string $html
+ * @return string text version of the given html string
+ */
+ public static function htmlToText( $html ) {
+ return trim( html_entity_decode( strip_tags( $html ),
ENT_QUOTES ) );
+ }
}
diff --git a/includes/EmailBatch.php b/includes/EmailBatch.php
index 61f8db6..2635323 100644
--- a/includes/EmailBatch.php
+++ b/includes/EmailBatch.php
@@ -5,18 +5,35 @@
*/
class MWEchoEmailBatch {
- // the user to be notified
+ /**
+ * @var User the user to be notified
+ */
protected $mUser;
- // list of email content
- protected $content = array();
- // the last notification event of this batch
+ /**
+ * @var Language
+ */
+ protected $language;
+
+ /**
+ * @var EchoEvent[] events included in this email
+ */
+ protected $events = array();
+
+ /**
+ * @var EchoEvent the last notification event of this batch
+ */
protected $lastEvent;
- // the event count, this count is supported up to self::$displaySize + 1
+
+ /**
+ * @var int the event count, this count is supported up to
self::$displaySize + 1
+ */
protected $count = 0;
- // number of bundle events to include in an email, we couldn't include
- // all events in a batch email
+ /**
+ * @var int number of bundle events to include in an email,
+ * we cannot include all events in a batch email
+ */
protected static $displaySize = 20;
/**
@@ -24,6 +41,7 @@
*/
public function __construct( User $user ) {
$this->mUser = $user;
+ $this->language = wfGetLangObj( $this->mUser->getOption(
'language' ) );
}
/**
@@ -104,7 +122,8 @@
break;
}
$event = EchoEvent::newFromRow( $row );
- $this->appendContent( $event,
$row->eeb_event_hash );
+ $event->setBundleHash( $row->eeb_event_hash );
+ $this->events[] = $event;
}
$this->sendEmail();
@@ -201,21 +220,6 @@
}
/**
- * Add individual event template to the big email content
- *
- * @param EchoEvent $event
- * @param string $hash
- */
- protected function appendContent( EchoEvent $event, $hash ) {
- // get the category for this event
- $category = $event->getCategory();
- $event->setBundleHash( $hash );
- $email = EchoNotificationController::formatNotification(
$event, $this->mUser, 'email', 'emaildigest' );
-
- $this->content[$category][] = $email;
- }
-
- /**
* Clear "processed" events in the queue, processed could be: email
sent, invalid, users do not want to receive emails
*/
public function clearProcessedEvent() {
@@ -250,34 +254,34 @@
$emailDeliveryMode = 'daily_digest';
}
- // Echo digest email mode
- $emailDigest = new EchoEmailDigest( $this->mUser,
$this->content, $frequency );
-
- $textEmailFormatter = new EchoTextEmailFormatter( $emailDigest
);
-
- $body = $textEmailFormatter->formatEmail();
+ $textEmailDigestFormatter = new
EchoPlainTextDigestEmailFormatter( $this->mUser, $this->language, $frequency );
+ $content = $textEmailDigestFormatter->format( $this->events,
'email' );
$format = MWEchoNotifUser::newFromUser( $this->mUser
)->getEmailFormat();
if ( $format == EchoHooks::EMAIL_FORMAT_HTML ) {
- $htmlEmailFormatter = new EchoHTMLEmailFormatter(
$emailDigest );
- $body = array(
- 'text' => $body,
- 'html' => $htmlEmailFormatter->formatEmail()
- );
- }
- // Give grep a chance to find the usages:
- // echo-email-batch-subject-daily,
echo-email-batch-subject-weekly
- $subject = wfMessage( 'echo-email-batch-subject-' . $frequency )
- ->inLanguage( $this->mUser->getOption( 'language' ) )
- ->params( $this->count, $this->count )->text();
+ $formattedEvents = array();
+ foreach ( $this->events as $event ) {
+ $category = $event->getCategory();
+ $formatted =
EchoNotificationController::formatNotification( $event, $this->mUser, 'email',
'emaildigest' );
+ $formattedEvents[ $category ][] = $formatted;
+ }
+
+ $emailDigest = new EchoEmailDigest( $this->mUser,
$formattedEvents, $frequency );
+ $htmlEmailFormatter = new EchoHTMLEmailFormatter(
$emailDigest );
+ $multipartBody = array(
+ 'text' => $content['body'],
+ 'html' => $htmlEmailFormatter->formatEmail(),
+ );
+ $content['body'] = $multipartBody;
+ }
$toAddress = MailAddress::newFromUser( $this->mUser );
$fromAddress = new MailAddress( $wgNotificationSender,
EchoHooks::getNotificationSenderName() );
$replyTo = new MailAddress( $wgNotificationSender,
$wgNotificationReplyName );
// @Todo Push the email to job queue or just send it out
directly?
- UserMailer::send( $toAddress, $fromAddress, $subject, $body,
array( 'replyTo' => $replyTo ) );
+ UserMailer::send( $toAddress, $fromAddress,
$content['subject'], $content['body'], array( 'replyTo' => $replyTo ) );
MWEchoEventLogging::logSchemaEchoMail( $this->mUser,
$emailDeliveryMode );
}
diff --git a/includes/Notifier.php b/includes/Notifier.php
index fa99840..c93c997 100644
--- a/includes/Notifier.php
+++ b/includes/Notifier.php
@@ -98,7 +98,10 @@
// Since we are sending a single email, should
set the bundle hash to null
// if it is set with a value from somewhere else
$event->setBundleHash( null );
- $email =
EchoNotificationController::formatNotification( $event, $user, 'email', 'email'
);
+ $email = self::generateEmail( $event, $user );
+ if ( !$email ) {
+ return false;
+ }
$subject = $email['subject'];
$body = $email['body'];
$options = array( 'replyTo' => $replyAddress );
@@ -110,4 +113,21 @@
return true;
}
+
+ /**
+ * @param EchoEvent $event
+ * @param User $user
+ * @return bool|array An array of 'subject' and 'body', or false if
things went wrong
+ */
+ private static function generateEmail( EchoEvent $event, User $user ) {
+ $emailFormat = MWEchoNotifUser::newFromUser( $user
)->getEmailFormat();
+ if ( $emailFormat === EchoHooks::EMAIL_FORMAT_PLAIN_TEXT ) {
+ $lang = wfGetLangObj( $user->getOption( 'language' ) );
+ $formatter = new EchoPlainTextEmailFormatter( $user,
$lang );
+ return $formatter->format( $event );
+ } else {
+ // @todo get rid of this
+ return EchoNotificationController::formatNotification(
$event, $user, 'email', 'email' );
+ }
+ }
}
diff --git a/includes/formatters/EchoEventDigestFormatter.php
b/includes/formatters/EchoEventDigestFormatter.php
new file mode 100644
index 0000000..e7ffd16
--- /dev/null
+++ b/includes/formatters/EchoEventDigestFormatter.php
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * Abstract class for formatters that process multiple events.
+ *
+ * The formatter does not maintain any state except for the
+ * arguments passed in the constructor (user and language)
+ */
+abstract class EchoEventDigestFormatter {
+ public function __construct( User $user, Language $language ) {
+ $this->user = $user;
+ $this->language = $language;
+ }
+
+ /**
+ * Equivalent to IContextSource::msg for the current
+ * language
+ *
+ * @return Message
+ */
+ protected function msg( /* ,,, */ ) {
+ /**
+ * @var Message $msg
+ */
+ $msg = call_user_func_array( 'wfMessage', func_get_args() );
+ $msg->inLanguage( $this->language );
+
+ return $msg;
+ }
+
+ /**
+ * @param EchoEvent[] $events
+ * @param string $distributionType 'web' or 'email'
+ * @return array|bool|string Output format depends on implementation,
false if it cannot be formatted
+ */
+ final public function format( array $events, $distributionType ) {
+ $models = array();
+ foreach ( $events as $event ) {
+ $model = EchoEventPresentationModel::factory( $event,
$this->language, $this->user, $distributionType );
+ if ( $model->canRender() ) {
+ $models[] = $model;
+ }
+ }
+
+ return $this->formatModels( $models );
+ }
+
+ /**
+ * @param EchoEventPresentationModel[] $models
+ * @return string|array
+ */
+ abstract protected function formatModels( array $models );
+}
diff --git a/includes/formatters/EchoEventFormatter.php
b/includes/formatters/EchoEventFormatter.php
index c7aef95..b3a76a7 100644
--- a/includes/formatters/EchoEventFormatter.php
+++ b/includes/formatters/EchoEventFormatter.php
@@ -18,8 +18,24 @@
}
/**
+ * Equivalent to IContextSource::msg for the current
+ * language
+ *
+ * @return Message
+ */
+ protected function msg( /* ,,, */ ) {
+ /**
+ * @var Message $msg
+ */
+ $msg = call_user_func_array( 'wfMessage', func_get_args() );
+ $msg->inLanguage( $this->language );
+
+ return $msg;
+ }
+
+ /**
* @param EchoEvent $event
- * @return string|bool Output format depends on implementation, false
if it cannot be formatted
+ * @return string|array|bool Output format depends on implementation,
false if it cannot be formatted
*/
final public function format( EchoEvent $event ) {
$model = EchoEventPresentationModel::factory( $event,
$this->language, $this->user );
@@ -32,7 +48,7 @@
/**
* @param EchoEventPresentationModel $model
- * @return string
+ * @return string|array
*/
abstract protected function formatModel( EchoEventPresentationModel
$model );
}
diff --git a/includes/formatters/EchoPlainTextDigestEmailFormatter.php
b/includes/formatters/EchoPlainTextDigestEmailFormatter.php
new file mode 100644
index 0000000..df31a3b
--- /dev/null
+++ b/includes/formatters/EchoPlainTextDigestEmailFormatter.php
@@ -0,0 +1,78 @@
+<?php
+
+class EchoPlainTextDigestEmailFormatter extends EchoEventDigestFormatter {
+
+ /**
+ * @var string 'daily' or 'weekly'
+ */
+ protected $digestMode;
+
+ public function __construct( User $user, Language $language,
$digestMode ) {
+ parent::__construct( $user, $language );
+ $this->digestMode = $digestMode;
+ }
+
+ /**
+ * @param EchoEventPresentationModel[] $models
+ * @return array of the following format:
+ * [ 'body' => formatted email body,
+ * 'subject' => formatted email subject ]
+ */
+ protected function formatModels( array $models ) {
+ $content = array();
+ foreach ( $models as $model ) {
+ $content[$model->getCategory()][] =
EchoDiscussionParser::htmlToText( $model->getHeaderMessage()->parse() );
+ }
+
+ ksort( $content );
+
+ // echo-email-batch-body-intro-daily
+ // echo-email-batch-body-intro-weekly
+ $text = $this->msg( 'echo-email-batch-body-intro-' .
$this->digestMode )
+ ->params( $this->user->getName() )->text();
+
+ // Does this need to be a message?
+ $bullet = $this->msg( 'echo-email-batch-bullet' )->text();
+
+ foreach ( $content as $type => $items ) {
+ $text .= "\n\n--\n\n";
+ $text .= $this->getCategoryTitle( $type, count( $items
) );
+ $text .= "\n";
+ foreach ( $items as $item ) {
+ $text .= "\n$bullet $item";
+ }
+ }
+
+ $colon = $this->msg( 'colon-separator' )->text();
+ $text .= "\n\n--\n\n";
+ $viewAll = $this->msg(
'echo-email-batch-link-text-view-all-notifications' )->text();
+ $link = SpecialPage::getTitleFor( 'Notifications'
)->getFullURL( '', false, PROTO_CANONICAL );
+ $text .= "$viewAll$colon <$link>";
+
+ $plainTextFormatter = new EchoPlainTextEmailFormatter(
$this->user, $this->language );
+
+ $text .= "\n\n{$plainTextFormatter->getFooter()}";
+
+ // echo-email-batch-subject-daily
+ // echo-email-batch-subject-weekly
+ $subject = $this->msg( 'echo-email-batch-subject-' .
$this->digestMode )
+ ->numParams( count( $models ), count( $models ) )
+ ->text();
+
+ return array(
+ 'subject' => $subject,
+ 'body' => $text,
+ );
+ }
+
+ /**
+ * @param string $type Notification type
+ * @param int $count Number of notifications in this type's section
+ * @return string Formatted category section title
+ */
+ private function getCategoryTitle( $type, $count ) {
+ return $this->msg( "echo-category-title-$type" )
+ ->numParams( $count )
+ ->text();
+ }
+}
diff --git a/includes/formatters/EchoPlainTextEmailFormatter.php
b/includes/formatters/EchoPlainTextEmailFormatter.php
new file mode 100644
index 0000000..9d7d819
--- /dev/null
+++ b/includes/formatters/EchoPlainTextEmailFormatter.php
@@ -0,0 +1,54 @@
+<?php
+
+class EchoPlainTextEmailFormatter extends EchoEventFormatter {
+ protected function formatModel( EchoEventPresentationModel $model ) {
+
+ $subject = EchoDiscussionParser::htmlToText(
$model->getSubjectMessage()->parse() );
+
+ $text = EchoDiscussionParser::htmlToText(
$model->getHeaderMessage()->parse() );
+
+ $text .= "\n\n";
+
+ $bodyMsg = $model->getBodyMessage();
+ if ( $bodyMsg ) {
+ $text .= EchoDiscussionParser::htmlToText(
$bodyMsg->parse() );
+ }
+
+ $primaryLink = $model->getPrimaryLink();
+
+ $primaryUrl = wfExpandUrl( $primaryLink['url'], PROTO_CANONICAL
);
+ $colon = $this->msg( 'colon-separator' )->text();
+ $text .= "\n\n{$primaryLink['label']}$colon <$primaryUrl>";
+
+ foreach ( array_filter( $model->getSecondaryLinks() ) as
$secondaryLink ) {
+ $url = wfExpandUrl( $secondaryLink['url'],
PROTO_CANONICAL );
+ $text .= "\n\n{$secondaryLink['label']}$colon <$url>";
+ }
+
+ // Footer
+ $text .= "\n\n{$this->getFooter()}";
+
+ return array(
+ 'body' => $text,
+ 'subject' => $subject,
+ );
+ }
+
+ /**
+ * @return string
+ */
+ public function getFooter() {
+ global $wgEchoEmailFooterAddress;
+
+ $footerMsg = $this->msg( 'echo-email-plain-footer' )->text();
+ $prefsUrl = SpecialPage::getTitleFor( 'Preferences', false,
'mw-prefsection-echo' )
+ ->getFullURL( '', false, PROTO_CANONICAL );
+ $text = "--\n\n$footerMsg\n$prefsUrl";
+
+ if ( strlen( $wgEchoEmailFooterAddress ) ) {
+ $text .= "\n\n$wgEchoEmailFooterAddress";
+ }
+
+ return $text;
+ }
+}
diff --git a/includes/formatters/EventPresentationModel.php
b/includes/formatters/EventPresentationModel.php
index 9e5eb98..c1679ae 100644
--- a/includes/formatters/EventPresentationModel.php
+++ b/includes/formatters/EventPresentationModel.php
@@ -57,15 +57,22 @@
private $bundledEvents;
/**
+ * @var string 'web' or 'email'
+ */
+ private $distributionType;
+
+ /**
* @param EchoEvent $event
* @param Language|string $language
* @param User $user Only used for permissions checking and GENDER
+ * @param string $distributionType
*/
- protected function __construct( EchoEvent $event, $language, User $user
) {
+ protected function __construct( EchoEvent $event, $language, User
$user, $distributionType ) {
$this->event = $event;
$this->type = $event->getType();
$this->language = wfGetLangObj( $language );
$this->user = $user;
+ $this->distributionType = $distributionType;
}
/**
@@ -84,14 +91,33 @@
* @param EchoEvent $event
* @param Language|string $language
* @param User $user
+ * @param string $distributionType 'web' or 'email'
* @return EchoEventPresentationModel
*/
- public static function factory( EchoEvent $event, $language, User $user
) {
+ public static function factory( EchoEvent $event, $language, User
$user, $distributionType = 'web' ) {
global $wgEchoNotifications;
// @todo don't depend upon globals
$class =
$wgEchoNotifications[$event->getType()]['presentation-model'];
- return new $class( $event, $language, $user );
+ return new $class( $event, $language, $user, $distributionType
);
+ }
+
+ /**
+ * Get the type of event
+ *
+ * @return string
+ */
+ final public function getType() {
+ return $this->type;
+ }
+
+ /**
+ * Get the category of event
+ *
+ * @return string
+ */
+ final public function getCategory() {
+ return $this->event->getCategory();
}
/**
@@ -126,9 +152,22 @@
$eventMapper = new EchoEventMapper();
$this->bundledEvents = $eventMapper->fetchByUserBundleHash(
$this->user,
- $this->event->getBundleHash()
+ $this->event->getBundleHash(),
+ $this->distributionType
// default params: web, DESC, limit=250
);
+
+ // Filter out the current event.
+ // This should go away with T120153 when we externalize the
fetching of bundled events.
+ if ( $this->distributionType === 'email' ) {
+ $currentEventId = $this->event->getId();
+ $this->bundledEvents = array_filter(
+ $this->bundledEvents,
+ function ( EchoEvent $event ) use (
$currentEventId ) {
+ return $currentEventId !==
$event->getId();
+ }
+ );
+ }
return $this->bundledEvents;
}
@@ -310,6 +349,30 @@
}
/**
+ * @return string Message key that will be used in getSubjectMessage
+ */
+ protected function getSubjectMessageKey() {
+ return "notification-subject-{$this->type}";
+ }
+
+ /**
+ * Get a message object and add the performer's name as
+ * a parameter. It is expected that subclasses will override
+ * this. The output of the message should be plaintext.
+ *
+ * @return Message
+ */
+ public function getSubjectMessage() {
+ $msg = $this->getMessageWithAgent(
$this->getSubjectMessageKey() );
+ if ( $msg->isDisabled() ) {
+ // Back-compat for models that haven't been updated yet
+ $msg = $this->getHeaderMessage();
+ }
+
+ return $msg;
+ }
+
+ /**
* Get a message for the notification's body, false if it has no body
*
* @return bool|Message
diff --git a/includes/mapper/EventMapper.php b/includes/mapper/EventMapper.php
index f75b323..c5fbfc5 100644
--- a/includes/mapper/EventMapper.php
+++ b/includes/mapper/EventMapper.php
@@ -62,12 +62,12 @@
*
* @param $user User
* @param $bundleHash string the bundle hash
- * @param $type string distribution type
+ * @param $distributionType string distribution medium: 'web' or 'email'
* @param $order string 'ASC'/'DESC'
* @param $limit int
* @return EchoEvent[]
*/
- public function fetchByUserBundleHash( User $user, $bundleHash, $type =
'web', $order = 'DESC', $limit = 250 ) {
+ public function fetchByUserBundleHash( User $user, $bundleHash,
$distributionType = 'web', $order = 'DESC', $limit = 250 ) {
$dbr = $this->dbFactory->getEchoDb( DB_SLAVE );
// We only display 99+ if the number is over 100, we can do
limit 250, this should
@@ -76,7 +76,7 @@
// 1. it will not scale for large volume data
// 2. notification may have random grouping iterator
// 3. agent may be anonymous, can't do distinct over two
columns: event_agent_id and event_agent_ip
- if ( $type == 'web' ) {
+ if ( $distributionType == 'web' ) {
$res = $dbr->select(
array( 'echo_notification', 'echo_event' ),
array( 'event_agent_id', 'event_agent_ip',
'event_extra',
--
To view, visit https://gerrit.wikimedia.org/r/249885
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4eceaf521315adab7429a8a73ffca70ebcddab86
Gerrit-PatchSet: 22
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits