From fd080b7043319e1aeb0fed792b1567925b9ee778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Thu, 3 Jun 2021 01:24:30 +0200 Subject: [PATCH] Ensure you can't get duplicate notifs for edits to your user talk page We don't display [subscribe] buttons on your user talk page, but the API still allows those subscriptions. Use the same approach as for mentions to ensure this doesn't cause duplicate notifications. Remove some code in SubscribedNewCommentPresentationModel, now guaranteed to be unused. Change-Id: I99a276a48d8562552ed2c54cc0323e8e428845fd --- includes/Hooks/EchoHooks.php | 5 ++++- .../SubscribedNewCommentPresentationModel.php | 13 +------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/includes/Hooks/EchoHooks.php b/includes/Hooks/EchoHooks.php index 76c2a5c04..4ec6cc999 100644 --- a/includes/Hooks/EchoHooks.php +++ b/includes/Hooks/EchoHooks.php @@ -46,11 +46,14 @@ class EchoHooks { 'user-locators' => [ 'MediaWiki\\Extension\\DiscussionTools\\Notifications\\EventDispatcher::locateSubscribedUsers' ], + // Exclude mentioned users and talk page owner from our notification, to avoid + // duplicate notifications for a single comment 'user-filters' => [ [ "EchoUserLocator::locateFromEventExtra", [ "mentioned-users" ] - ] + ], + "EchoUserLocator::locateTalkPageOwner" ], 'presentation-model' => 'MediaWiki\\Extension\\DiscussionTools\\Notifications\\SubscribedNewCommentPresentationModel', diff --git a/includes/Notifications/SubscribedNewCommentPresentationModel.php b/includes/Notifications/SubscribedNewCommentPresentationModel.php index efb507517..9676abdaa 100644 --- a/includes/Notifications/SubscribedNewCommentPresentationModel.php +++ b/includes/Notifications/SubscribedNewCommentPresentationModel.php @@ -37,7 +37,7 @@ class SubscribedNewCommentPresentationModel extends EchoEventPresentationModel { * @inheritDoc */ public function getIconType() { - return $this->isUserTalkPage() ? 'edit-user-talk' : 'chat'; + return 'chat'; } /** @@ -118,17 +118,6 @@ class SubscribedNewCommentPresentationModel extends EchoEventPresentationModel { return $this->language->truncateForVisual( $content, EchoDiscussionParser::DEFAULT_SNIPPET_LENGTH ); } - /** - * @return bool - */ - protected function isUserTalkPage() { - // Would like to do $this->event->getTitle()->equals( $this->user->getTalkPage() ) - // but $this->user is private in the parent class - $username = $this->getViewingUserForGender(); - return $this->event->getTitle()->getNamespace() === NS_USER_TALK && - $this->event->getTitle()->getText() === $username; - } - /** * @inheritDoc */