Addshore has uploaded a new change for review.
https://gerrit.wikimedia.org/r/290198
Change subject: DRAFT Echo notifications on mention failure
......................................................................
DRAFT Echo notifications on mention failure
This introduces Echo notifications for when mentions
fail due to too many users being mentioned.
TODO:
- Cover more failures
- better i18n messages and docs (add params)
- General cleanup...
- Add bug ticket number!!!!
Change-Id: Ib367c304c05fd38dd141f3749a3b95f87b03afde
---
M Echo.php
M autoload.php
M i18n/en.json
M i18n/qqq.json
M includes/DiscussionParser.php
A includes/formatters/MentionFailPresentationModel.php
6 files changed, 79 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/98/290198/1
diff --git a/Echo.php b/Echo.php
index a284adf..9db77d4 100644
--- a/Echo.php
+++ b/Echo.php
@@ -275,6 +275,10 @@
'priority' => 4,
'tooltip' => 'echo-pref-tooltip-mention',
),
+ 'mentionfail' => array(
+ 'priority' => 4,
+ 'tooltip' => 'echo-pref-tooltip-mentionfail',
+ ),
'emailuser' => array(
'priority' => 9,
'tooltip' => 'echo-pref-tooltip-emailuser',
@@ -315,6 +319,9 @@
'path' => "$echoIconPath/link-blue.svg",
),
'mention' => array(
+ 'path' => "$echoIconPath/mention.svg",
+ ),
+ 'mentionfail' => array(
'path' => "$echoIconPath/mention.svg",
),
'reviewed' => array(
@@ -452,6 +459,28 @@
'email-body-batch-params' => array( 'agent', 'title',
'section-title', 'main-title-text', 'user' ),
'icon' => 'mention',
),
+ 'mentionfail' => array(
+ 'user-locators' => array(
+ 'EchoUserLocator::locateEventAgent'
+ ),
+ // Only send 'web' notification
+ 'notify-type-availability' => array(
+ 'email' => false,
+ ),
+ 'primary-link' => array(
+ 'message' => 'notification-link-text-view-mentionfail',
+ 'destination' => 'section'
+ ),
+ 'secondary-link' => array( 'message' =>
'notification-link-text-view-changes', 'destination' => 'diff' ),
+ 'category' => 'mentionfail',
+ 'group' => 'interactive',
+ 'section' => 'alert',
+ 'presentation-model' => 'EchoMentionFailPresentationModel',
+ 'title-message' => 'notification-mentionfail-tooMany',
+ 'email-subject-message' =>
'notification-mentionfail-email-subject',
+ 'email-body-batch-message' =>
'notification-mentionfail-email-batch-body',
+ 'icon' => 'mentionfail',
+ ),
'user-rights' => array(
EchoAttributeManager::ATTR_LOCATORS => array(
array( 'EchoUserLocator::locateFromEventExtra', array(
'user' ) ),
diff --git a/autoload.php b/autoload.php
index 94047b0..0ad73ec 100644
--- a/autoload.php
+++ b/autoload.php
@@ -62,6 +62,7 @@
'EchoLocalCache' => __DIR__ . '/includes/cache/LocalCache.php',
'EchoMentionFormatter' => __DIR__ .
'/includes/formatters/MentionFormatter.php',
'EchoMentionPresentationModel' => __DIR__ .
'/includes/formatters/MentionPresentationModel.php',
+ 'EchoMentionFailPresentationModel' => __DIR__ .
'/includes/formatters/MentionFailPresentationModel.php',
'EchoModelFormatter' => __DIR__ .
'/includes/formatters/EchoModelFormatter.php',
'EchoMultipleIterator' => __DIR__ .
'/includes/iterator/MultipleIterator.php',
'EchoNotRecursiveIterator' => __DIR__ .
'/includes/iterator/NotRecursiveIterator.php',
diff --git a/i18n/en.json b/i18n/en.json
index d74a4ae..be223a0 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -64,6 +64,7 @@
"echo-category-title-article-linked": "Page {{PLURAL:$1|link|links}}",
"echo-category-title-reverted": "Edit {{PLURAL:$1|revert|reverts}}",
"echo-category-title-mention": "{{PLURAL:$1|Mention|Mentions}}",
+ "echo-category-title-mentionfail": "Failed
{{PLURAL:$1|Mention|Mentions}}",
"echo-category-title-other": "{{PLURAL:$1|Other}}",
"echo-category-title-system": "{{PLURAL:$1|System}}",
"echo-category-title-user-rights": "{{PLURAL:$1|User rights change|User
rights changes}}",
@@ -72,6 +73,7 @@
"echo-pref-tooltip-article-linked": "Notify me when someone links to a
page I created from an article page.",
"echo-pref-tooltip-reverted": "Notify me when someone reverts an edit I
made, by using the undo or rollback tool.",
"echo-pref-tooltip-mention": "Notify me when someone links to my user
page.",
+ "echo-pref-tooltip-mentionfail": "Notify me when my edit failed to
mention users.",
"echo-pref-tooltip-user-rights": "Notify me when someone changes my
user rights.",
"echo-pref-tooltip-emailuser": "Notify me when someone sends me an
email.",
"echo-no-agent": "[Nobody]",
@@ -121,6 +123,7 @@
"notification-link-text-collapse-all": "Collapse",
"notification-link-text-view-message": "View message",
"notification-link-text-view-mention": "View mention",
+ "notification-link-text-view-mentionfail": "View mention failure",
"notification-link-text-view-changes": "{{GENDER:$1|View}} changes",
"notification-link-text-view-page": "View page",
"notification-link-text-view-edit": "View edit",
@@ -148,6 +151,9 @@
"notification-header-mention-agent-talkpage-nosection": "$1
{{GENDER:$2|mentioned}} {{GENDER:$3|you}} on
<strong>{{GENDER:$2|his|her|their}} talk page</strong>.",
"notification-header-mention-article-talkpage": "$1
{{GENDER:$2|mentioned}} {{GENDER:$3|you}} on the <strong>$4</strong> talk page
in \"<strong>$5</strong>\".",
"notification-header-mention-article-talkpage-nosection": "$1
{{GENDER:$2|mentioned}} {{GENDER:$3|you}} on the <strong>$4</strong> talk
page.",
+ "notification-header-mentionfail": "One of your mentions failed.",
+ "notification-body-mentionfail": "$1",
+ "notification-mentionfail-tooMany": "Your mention of users failed due
to reaching the maximum number of users.",
"notification-user-rights-add": "You are now a member of
{{PLURAL:$2|this group|these groups}}: $1",
"notification-user-rights-remove": "You are no longer a member of
{{PLURAL:$2|this group|these groups}}: $1",
"notification-user-rights": "Your user rights
[[Special:Log/rights/$1|were {{GENDER:$1|changed}}]] by [[User:$1|$1]]. $2.
[[Special:ListGroupRights|Learn more]]",
@@ -182,6 +188,8 @@
"notification-reverted-email-batch-body2": "Your {{PLURAL:$3|edit on $2
has been|edits on $2 have been}} {{GENDER:$1|reverted}} by $1.",
"notification-mention-email-subject": "$1 {{GENDER:$1|mentioned}}
{{GENDER:$2|you}} on {{SITENAME}}",
"notification-mention-email-batch-body": "$1 {{GENDER:$1|mentioned}}
{{GENDER:$5|you}} on the $4 talk page in \"$3\".",
+ "notification-mentionfail-email-subject": "A mention failed",
+ "notification-mentionfail-email-batch-body": "A mention failed!!!!",
"notification-mention-nosection-email-batch-body": "$1
{{GENDER:$1|mentioned}} you on the $2 talk page.",
"notification-user-rights-email-subject": "Your user rights have
changed on {{SITENAME}}",
"notification-user-rights-email-batch-body": "Your user rights were
{{GENDER:$1|changed}} by $1. $2.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 51c540e..ca64a7c 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -55,6 +55,7 @@
"echo-category-title-article-linked": "This is a short title for
notification category.\n\nUsed in a list of options under the heading
{{msg-mw|Prefs-echosubscriptions}} in Special:Preferences. As far as I can see
this always needs to be a plural for an unspecified number.\n\nIt used to be
used as <code>$1</code> in {{msg-mw|Echo-dismiss-message}}, but this message is
no longer used, apparently.\n\nParameters:\n* $1 - number of messages, for
PLURAL support\n{{Related|Echo-category-title}}",
"echo-category-title-reverted": "This is a short title for notification
category.\n\nUsed in a list of options under the heading
{{msg-mw|Prefs-echosubscriptions}} in Special:Preferences. As far as I can see
this always needs to be a plural for an unspecified number.\n\nIt used to be
used as <code>$1</code> in {{msg-mw|Echo-dismiss-message}}, but this message is
no longer used, apparently.\n\nParameters:\n* $1 - number of messages, for
PLURAL support\n{{Related|Echo-category-title}}",
"echo-category-title-mention": "This is a short title for notification
category.\n\nUsed in a list of options under the heading
{{msg-mw|Prefs-echosubscriptions}} in Special:Preferences. As far as I can see
this always needs to be a plural for an unspecified number.\n\nIt used to be
used as <code>$1</code> in {{msg-mw|Echo-dismiss-message}}, but this message is
no longer used, apparently.\n\nParameters:\n* $1 - number of messages, for
PLURAL support\n{{Related|Echo-category-title}}\n{{Identical|Mention}}",
+ "echo-category-title-mentionfail": "This is a short title for
notification category.\n\nUsed in a list of options under the heading
{{msg-mw|Prefs-echosubscriptions}} in Special:Preferences. As far as I can see
this always needs to be a plural for an unspecified number.\n\nIt used to be
used as <code>$1</code> in {{msg-mw|Echo-dismiss-message}}, but this message is
no longer used, apparently.\n\nParameters:\n* $1 - number of messages, for
PLURAL support\n{{Related|Echo-category-title}}",
"echo-category-title-other": "This is a short title for notification
category.\n\nUsed in a list of options under the heading
{{msg-mw|Prefs-echosubscriptions}} in Special:Preferences. As far as I can see
this always needs to be a plural for an unspecified number.\n\nIt used to be
used as <code>$1</code> in {{msg-mw|Echo-dismiss-message}}, but this message is
no longer used, apparently.\n\nParameters:\n* $1 - number of messages, for
PLURAL support\n{{Related|Echo-category-title}}\n{{Identical|Other}}",
"echo-category-title-system": "This is a short title for notification
category.\n\nUsed in a list of options under the heading
{{msg-mw|Prefs-echosubscriptions}} in Special:Preferences. As far as I can see
this always needs to be a plural for an unspecified number.\n\nIt used to be
used as <code>$1</code> in {{msg-mw|Echo-dismiss-message}}, but this message is
no longer used, apparently.\n\nParameters:\n* $1 - number of messages, for
PLURAL support\n{{Related|Echo-category-title}}\n{{Identical|System}}",
"echo-category-title-user-rights": "This is a short title for
notification category.\n\nUsed in a list of options under the heading
{{msg-mw|Prefs-echosubscriptions}} in Special:Preferences. As far as I can see
this always needs to be a plural for an unspecified number.\n\nIt used to be
used as <code>$1</code> in {{msg-mw|Echo-dismiss-message}}, but this message is
no longer used, apparently.\n\nParameters:\n* $1 - number of messages, for
PLURAL support\n{{Related|Echo-category-title}}",
@@ -63,6 +64,7 @@
"echo-pref-tooltip-article-linked": "This is a short description of the
article-linked notification category.\n{{Related|Echo-pref-tooltip}}",
"echo-pref-tooltip-reverted": "This is a short description of the
tooltip-reverted notification category.\n{{Related|Echo-pref-tooltip}}",
"echo-pref-tooltip-mention": "This is a short description of the
mention notification category.\n{{Related|Echo-pref-tooltip}}",
+ "echo-pref-tooltip-mentionfail": "This is a short description of the
mention fail notification category.\n{{Related|Echo-pref-tooltip}}",
"echo-pref-tooltip-user-rights": "This is a short description of the
user rights changes notification category\n{{Related|Echo-pref-tooltip}}",
"echo-pref-tooltip-emailuser": "This is a short description of the user
email notification category\n{{Related|Echo-pref-tooltip}}",
"echo-no-agent": "Shown in place of a username in a notification\n\tif
the notification has no specified user.",
@@ -112,6 +114,7 @@
"notification-link-text-collapse-all": "Label for the button that
collapses a bundled notification.\n{{Identical|Collapse}}",
"notification-link-text-view-message": "Label for button that links to
a message on your talk page.\n{{Identical|View message}}",
"notification-link-text-view-mention": "Label for button that links to
a discussion where you were mentioned.",
+ "notification-link-text-view-mentionfail": "Label for button that links
to a discussion where your mentions failed.",
"notification-link-text-view-changes": "Label for button that links to
a \"diff\" view showing changes made to a page. This is an alternative to the
wording in {{msg-mw|notification-link-text-view-edit}}, which serves
essentially the same function. Paramters:\n* $1 - name of the user viewing the
notification, can be used for GENDER.\n{{Identical|View changes}}",
"notification-link-text-view-page": "Label for button that links to a
page.\n{{Identical|View page}}",
"notification-link-text-view-edit": "Label for button that links to a
\"diff\" view showing an edit made to a page. This is an alternative to the
wording in {{msg-mw|notification-link-text-view-changes}}, which serves
essentially the same function.",
@@ -139,6 +142,9 @@
"notification-header-mention-agent-talkpage-nosection":
"{{doc-singularthey}}\nHeader text for a notification when you are mentioned by
another user on their talk page.\n* $1 - user's name (not suitable for
GENDER).\n* $2 - user's name for use in GENDER.\n* $3 - name of the user
viewing the notification, can be used for GENDER",
"notification-header-mention-article-talkpage": "Header text for a
notification when you are mentioned by another user in a section on an article
talk page.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name
for use in GENDER.\n* $3 - name of the user viewing the notification, can be
used for GENDER\n* $4 - name of the article whose talk page you are mentioned
in (without namespace).\n* $5 - name of the section they were mentioned in",
"notification-header-mention-article-talkpage-nosection": "Header text
for a notification when you are mentioned by another user on an article talk
page.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name for
use in GENDER.\n* $3 - name of the user viewing the notification, can be used
for GENDER\n* $4 - name of the article whose talk page you are mentioned in
(without namespace)",
+ "notification-header-mentionfail": "Header text for a notification when
your mention has failed.",
+ "notification-body-mentionfail": "{{notranslate}}",
+ "notification-mention": "Format for displaying notifications of a
failed mention.",
"notification-user-rights-add": "Message indicating that a user was
added to a user group. Parameters:\n* $1 - a comma separated list of user
group names\n* $2 - the number of user groups, this is used for PLURAL
support\nSee also:\n* {{msg-mw|Notification-user-rights-remove}}",
"notification-user-rights-remove": "Message indicating that a user was
removed from a user group. Parameters:\n* $1 - a comma separated list of user
group names\n* $2 - the number of user groups, this is used for PLURAL
support\nSee also:\n* {{msg-mw|Notification-user-rights-add}}",
"notification-user-rights": "Format for displaying notifications of a
user right change in notification page.\n\nParameters:\n* $1 - the username of
the person who made the user right change. Can be used for GENDER support.\n*
$2 - a semicolon separated list of {{msg-mw|Notification-user-rights-add}},
{{msg-mw|Notification-user-rights-remove}}",
@@ -174,6 +180,8 @@
"notification-mention-email-subject": "Email subject. Parameters:\n* $1
- a username\n* $2 - name of the user viewing the notification, can be used for
GENDER\nSee also:\n* {{msg-mw|Notification-mention}}\n*
{{msg-mw|Notification-mention-flyout}}\n*
{{msg-mw|Notification-mention-email-batch-body}}",
"notification-mention-email-batch-body": "E-mail notification batch
body. Parameters:\n* $1 - a username, plaintext. Can be used for gender
support\n* $2 - (Unused) talk page title\n* $3 - the raw section title text\n*
$4 - the title text without namespace (a page title in any namespace)\n* $5 -
name of the user viewing the notification, can be used for GENDER\n\nSee
also:\n* {{msg-mw|Notification-mention}}\n*
{{msg-mw|Notification-mention-flyout}}\n*
{{msg-mw|Notification-mention-email-subject}}",
"notification-mention-nosection-email-batch-body": "E-mail notification
batch body. Parameters:\n* $1 - a username, plaintext. Can be used for gender
support\n* $2 - the title text without namespace (a page title in any
namespace)\n* $3 - name of the user viewing the notification, can be used for
GENDER\n\nSee also:\n* {{msg-mw|Notification-mention-nosection}}\n*
{{msg-mw|Notification-mention-nosection-flyout}}\n*
{{msg-mw|Notification-mention-email-subject}}",
+ "notification-mentionfail-email-subject": "Email subject.
Parameters:\n* $1 - a username\n* $2 - name of the user viewing the
notification, can be used for GENDER\nSee also:\n*
{{msg-mw|Notification-mentionfail}}\n*
{{msg-mw|Notification-mentionfail-flyout}}\n*
{{msg-mw|Notification-mentionfail-email-batch-body}}",
+ "notification-mentionfail-email-batch-body": "E-mail notification batch
body. Parameters:\n* $1 - a username, plaintext. Can be used for gender
support\n* $2 - (Unused) talk page title\n* $3 - the raw section title text\n*
$4 - the title text without namespace (a page title in any namespace)\n* $5 -
name of the user viewing the notification, can be used for GENDER\n\nSee
also:\n* {{msg-mw|Notification-mentionfail-email-subject}}",
"notification-user-rights-email-subject": "E-mail subject for user
rights notification\n\nSee also:\n* {{msg-mw|Notification-user-rights}}\n*
{{msg-mw|Notification-user-rights-email-batch-body}}",
"notification-user-rights-email-batch-body": "Email notification batch
body. Parameters:\n* $1 - a user name, plaintext. Can be used for gender
support.\n* $2 - a semicolon separated list of
{{msg-mw|notification-user-rights-add}},
{{msg-mw|notification-user-rights-remove}}",
"notification-timestamp-ago-seconds": "Label for the amount of time
since a notification has arrived in the case where it is under a minute. This
should be a very short string. $1 - Number of seconds",
diff --git a/includes/DiscussionParser.php b/includes/DiscussionParser.php
index 909723b..f1dd577 100644
--- a/includes/DiscussionParser.php
+++ b/includes/DiscussionParser.php
@@ -164,6 +164,20 @@
// If more than 50 users are being pinged this is
likely a spam/attack vector
// Don't send any mention notifications.
if ( $count > 50 ) {
+ EchoEvent::create( array(
+ 'type' => 'mentionfail',
+ 'title' => $title,
+ 'extra' => array(
+ //TODO probably don't need all
of this right now?
+ //TODO allow mention fail to
also cover other types of failure
+ 'content' => $content,
+ 'section-title' => $header,
+ 'revid' => $revision->getId(),
+ 'mentioned-users' =>
$mentionedUsers,
+ 'notifyAgent' => true
+ ),
+ 'agent' => $agent,
+ ) );
return;
}
}
diff --git a/includes/formatters/MentionFailPresentationModel.php
b/includes/formatters/MentionFailPresentationModel.php
new file mode 100644
index 0000000..a478d43
--- /dev/null
+++ b/includes/formatters/MentionFailPresentationModel.php
@@ -0,0 +1,19 @@
+<?php
+
+class EchoMentionFailPresentationModel extends EchoEventPresentationModel {
+
+ use EchoPresentationModelSectionTrait;
+
+ public function getIconType() {
+ return 'mentionfail';
+ }
+
+ public function getPrimaryLink() {
+ return array(
+ // Need FullURL so the section is included
+ 'url' => $this->getTitleWithSection()->getFullURL(),
+ 'label' => $this->msg(
'notification-link-text-view-mentionfail' )->text()
+ );
+ }
+
+}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/290198
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib367c304c05fd38dd141f3749a3b95f87b03afde
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits