Notifications: Handle suppressed topic titles in notification

EchoPresentationModelSection::getTruncatedSectionTitle() has a note that
it should not be called if ::exists() returned false. Among the reason
the section may not exist includes suppressing the revision where the
topic title was added or edited.

Add placeholder message text "(topic removed)", to be used in place of
the unavailable topic title. This is analogous to "(user removed)" which
would be shown along if the username is also suppressed.

Bug: T378261
Change-Id: I6db0872b8724323a5e15eb6a262c2c3d0bdd630d
This commit is contained in:
Ammarpad 2024-10-26 13:46:38 +01:00
parent ed132cc837
commit 4a25a985ff
3 changed files with 10 additions and 5 deletions

View file

@ -83,6 +83,7 @@
"discussiontools-notification-removed-topic-disable": "Stop receiving notifications like this",
"discussiontools-notification-removed-topic-disabled-title": "{{GENDER:|You}} will no longer receive notifications when a topic is archived or removed.",
"discussiontools-notification-removed-topic-disabled-body": "You can change this in [[Special:Preferences#mw-prefsection-echo-echosubscriptions|your preferences]].",
"discussiontools-notification-topic-hidden": "(topic removed)",
"discussiontools-notification-subscribed-new-comment-header": "$1 {{GENDER:$2|replied}} in \"<strong>$4</strong>\".",
"discussiontools-notification-subscribed-new-comment-header-bundled": "{{PLURAL:$1|One new reply|$1 new replies|100=99+ new replies}} in \"<strong>$3</strong>\".",
"discussiontools-notification-subscribed-new-comment-header-compact": "$1: <em>$3</em>.",

View file

@ -97,6 +97,7 @@
"discussiontools-notification-removed-topic-disable": "Button to disable notifications of the given type, shown below an Echo notification.",
"discussiontools-notification-removed-topic-disabled-title": "Title of notification popup shown when a user disables this type of Echo notifications.",
"discussiontools-notification-removed-topic-disabled-body": "Body of notification popup shown when a user disables this type of Echo notifications.",
"discussiontools-notification-topic-hidden": "Text shown instead of topic title when the topic title has been hidden and context user does not have permission to see it",
"discussiontools-notification-subscribed-new-comment-header": "Notification header text for when there is a reply on a topic. Parameters:\n* $1 - the formatted username of the user who replied to the topic\n* $2 - the username for gender purposes\n* $3 - title of the page\n* $4 - title of the topic.",
"discussiontools-notification-subscribed-new-comment-header-bundled": "Notification header text for when there is a multiple replies on a topic. Parameters:\n* $1 - the number of replies for display\n* $2 - the raw number of replies, for PLURAL\n* $3 - title of the topic.\n{{Related|discussiontools-notification-bundle}}",
"discussiontools-notification-subscribed-new-comment-header-compact": "{{optional}}\nNotification compact header text for when there is a reply on a topic. Parameters:\n* $1 - the formatted username of the user who replied to the topic\n* $2 - the username for gender purposes\n* $3 - excerpt of the reply.\n{{Related|discussiontools-notification-header-flow}}",

View file

@ -88,17 +88,20 @@ class SubscribedNewCommentPresentationModel extends EchoEventPresentationModel {
if ( $this->isBundled() ) {
$count = $this->getNotificationCountForOutput();
$msg = $this->msg( $this->getHeaderMessageKey() );
// Repeat is B/C until unused parameter is removed from translations
$msg->numParams( $count, $count );
$msg->plaintextParams( $this->section->getTruncatedSectionTitle() );
return $msg;
} else {
$msg = parent::getHeaderMessage();
$msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) );
$msg->plaintextParams( $this->section->getTruncatedSectionTitle() );
return $msg;
}
if ( $this->section->exists() ) {
$msg->plaintextParams( $this->section->getTruncatedSectionTitle() );
} else {
$msg->plaintextParams( $this->msg( 'discussiontools-notification-topic-hidden' )->text() );
}
return $msg;
}
/**