Mattflaschen has uploaded a new change for review. https://gerrit.wikimedia.org/r/304427
Change subject: Revert "Allow self mentions" ...................................................................... Revert "Allow self mentions" This reverts commit 0e234631853acdc9c9626ad82954762ac8806df0. Change-Id: I4389c7b93b2bbc117931a263b58a8f1cc30dca6c (cherry picked from commit 59568789fa695d2cff0577609aa6080fe4804208) --- M i18n/en.json M i18n/qqq.json M includes/DiscussionParser.php M includes/formatters/EventPresentationModel.php M includes/formatters/MentionPresentationModel.php M tests/phpunit/DiscussionParserTest.php 6 files changed, 12 insertions(+), 31 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo refs/changes/27/304427/1 diff --git a/i18n/en.json b/i18n/en.json index 658cd3d..1342f80 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -141,8 +141,6 @@ "notification-body-mention": "$1", "notification-header-mention-other": "$1 {{GENDER:$2|mentioned}} {{GENDER:$3|you}} on <strong>$4</strong> in \"<strong>$5</strong>\".", "notification-header-mention-other-nosection": "$1 {{GENDER:$2|mentioned}} {{GENDER:$3|you}} on <strong>$4</strong>.", - "notification-header-mention-self": "{{GENDER:$1|You}} {{GENDER:$1|mentioned}} {{GENDER:$1|yourself}} on <strong>$2</strong> in \"<strong>$3</strong>\".", - "notification-header-mention-self-nosection": "{{GENDER:$1|You}} {{GENDER:$1|mentioned}} {{GENDER:$1|yourself}} on <strong>$2</strong>.", "notification-header-mention-user-talkpage-v2": "$1 {{GENDER:$2|mentioned}} {{GENDER:$3|you}} on the <strong>user talk page {{GENDER:$5|of}} $4</strong> in \"<strong>$6</strong>\".", "notification-header-mention-user-talkpage-nosection": "$1 {{GENDER:$2|mentioned}} {{GENDER:$3|you}} on the <strong>user talk page {{GENDER:$5|of}} $4</strong>.", "notification-header-mention-agent-talkpage": "$1 {{GENDER:$2|mentioned}} {{GENDER:$3|you}} on <strong>{{GENDER:$2|his|her|their}} talk page</strong> in \"<strong>$4</strong>\".", diff --git a/i18n/qqq.json b/i18n/qqq.json index 5a33cad..ec987ae 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -134,8 +134,6 @@ "notification-body-mention": "{{notranslate}}", "notification-header-mention-other": "Header text for a notification when you are mentioned by another user in a section on a page that is not an article talk page or a user 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 page they were mentioned in (with namespace).\n* $5 - name of the section they were mentioned in", "notification-header-mention-other-nosection": "Header text for a notification when you are mentioned by another user on a page that is not an article talk page or a user 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 page they were mentioned in (with namespace)", - "notification-header-mention-self": "Header text for a notification when you mention yourself in a section.\n* $1 - user's name.\n* $2 - name of the page they were mentioned in (with namespace).\n* $3 - name of the section they were mentioned in", - "notification-header-mention-self-nosection": "Header text for a notification when you mention yourself.\n* $1 - user's name.\n* $2 - name of the page they were mentioned in (with namespace)", "notification-header-mention-user-talkpage-v2": "Header text for a notification when you are mentioned by another user in a section on a user 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 - formatted name of the user whose talk page you are mentioned in.\n* $5 - name of the user whose talk page you are mentioned in, can be used for GENDER\n* $6 - name of the section they were mentioned in", "notification-header-mention-user-talkpage-nosection": "Header text for a notification when you are mentioned by another user on a user 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 user whose talk page you are mentioned in\n* $5 - name of the user whose talk page you are mentioned in, can be used for GENDER", "notification-header-mention-agent-talkpage": "{{doc-singularthey}}\nHeader text for a notification when you are mentioned by another user in a section 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\n* $4 - name of the section they were mentioned in", diff --git a/includes/DiscussionParser.php b/includes/DiscussionParser.php index 5dc08a0..67f2fc1 100644 --- a/includes/DiscussionParser.php +++ b/includes/DiscussionParser.php @@ -146,7 +146,6 @@ return; } $content = self::stripHeader( $content ); - $content = self::stripSignature( $content, $title ); $userLinks = self::getUserLinks( $content, $title ); if ( !$userLinks ) { @@ -219,7 +218,6 @@ 'section-title' => $header, 'revid' => $revision->getId(), 'mentioned-users' => $userMentions['validMentions'], - 'notifyAgent' => true, ), 'agent' => $agent, ) ); @@ -294,13 +292,19 @@ continue; } - // 4. the user is the owner of the talk page + // 4. the user mentions themselves + if ( $user->getId() === $revisionUserId ) { + $stats->increment( 'echo.event.mention.error.sameUser' ); + continue; + } + + // 5. the user is the owner of the talk page if ( $title->getNamespace() === NS_USER_TALK && $title->getDBkey() === $dbk ) { $stats->increment( 'echo.event.mention.error.ownPage' ); continue; } - // 5. user does not exist + // 6. user does not exist if ( $user->getId() === 0 ) { $userMentions['unknownUsers'][] = str_replace( '_', ' ', $dbk ); $count++; diff --git a/includes/formatters/EventPresentationModel.php b/includes/formatters/EventPresentationModel.php index 4d1e39a..cb692e6 100644 --- a/includes/formatters/EventPresentationModel.php +++ b/includes/formatters/EventPresentationModel.php @@ -107,13 +107,6 @@ } /** - * @return User - */ - final public function getUser() { - return $this->user; - } - - /** * Get the category of event * * @return string diff --git a/includes/formatters/MentionPresentationModel.php b/includes/formatters/MentionPresentationModel.php index a332257..21d365b 100644 --- a/includes/formatters/MentionPresentationModel.php +++ b/includes/formatters/MentionPresentationModel.php @@ -12,11 +12,7 @@ } protected function getHeaderMessageKey() { - if ( $this->isSelfMention() ) { - return $this->hasSection() ? - 'notification-header-mention-self' : - 'notification-header-mention-self-nosection'; - } elseif ( $this->onArticleTalkpage() ) { + if ( $this->onArticleTalkpage() ) { return $this->hasSection() ? 'notification-header-mention-article-talkpage' : 'notification-header-mention-article-talkpage-nosection'; @@ -36,11 +32,7 @@ } public function getHeaderMessage() { - if ( $this->isSelfMention() ) { - $msg = $this->msg( $this->getHeaderMessageKey() ); - } else { - $msg = $this->getMessageWithAgent( $this->getHeaderMessageKey() ); - } + $msg = $this->getMessageWithAgent( $this->getHeaderMessageKey() ); $msg->params( $this->getViewingUserForGender() ); if ( $this->onArticleTalkpage() ) { @@ -127,10 +119,6 @@ private function isArticle() { $ns = $this->event->getTitle()->getNamespace(); return $ns === NS_MAIN || $ns === NS_TALK; - } - - private function isSelfMention() { - return $this->getUser()->equals( $this->event->getAgent() ); } protected function getSubjectMessageKey() { diff --git a/tests/phpunit/DiscussionParserTest.php b/tests/phpunit/DiscussionParserTest.php index e59f3a5..1e7e3c0 100644 --- a/tests/phpunit/DiscussionParserTest.php +++ b/tests/phpunit/DiscussionParserTest.php @@ -1374,9 +1374,9 @@ public function testGetUserMentions_ownMention() { $userName = 'Admin'; - $userId = User::newFromName( $userName )->getId(); + $userId = User::newFromName( 'Admin' )->getId(); $expectedUserMentions = array( - 'validMentions' => array( $userId => $userId ), + 'validMentions' => array(), 'unknownUsers' => array(), 'anonymousUsers' => array(), ); -- To view, visit https://gerrit.wikimedia.org/r/304427 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4389c7b93b2bbc117931a263b58a8f1cc30dca6c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: wmf/1.28.0-wmf.14 Gerrit-Owner: Mattflaschen <mflasc...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits