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
This commit is contained in:
Bartosz Dziewoński 2021-06-03 01:24:30 +02:00
parent 4353b68646
commit fd080b7043
2 changed files with 5 additions and 13 deletions

View file

@ -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',

View file

@ -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
*/