jenkins-bot has submitted this change and it was merged.
Change subject: Cleanup old notifications config
......................................................................
Cleanup old notifications config
* Remove old formatters
* Remove old notifications config
Bug: T121612
Change-Id: Ie082588ca63f5df824fc5da65635339ec8b829e2
---
M autoload.php
D includes/Notifications/Formatter.php
M includes/Notifications/Notifications.php
3 files changed, 0 insertions(+), 321 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/autoload.php b/autoload.php
index a63c0b6..e1e9857 100644
--- a/autoload.php
+++ b/autoload.php
@@ -253,10 +253,8 @@
'Flow\\Model\\UserTuple' => __DIR__ . '/includes/Model/UserTuple.php',
'Flow\\Model\\WikiReference' => __DIR__ .
'/includes/Model/WikiReference.php',
'Flow\\Model\\Workflow' => __DIR__ . '/includes/Model/Workflow.php',
- 'Flow\\NewTopicFormatter' => __DIR__ .
'/includes/Notifications/Formatter.php',
'Flow\\NewTopicPresentationModel' => __DIR__ .
'/includes/Notifications/NewTopicPresentationModel.php',
'Flow\\NotificationController' => __DIR__ .
'/includes/Notifications/Controller.php',
- 'Flow\\NotificationFormatter' => __DIR__ .
'/includes/Notifications/Formatter.php',
'Flow\\NotificationsUserLocator' => __DIR__ .
'/includes/Notifications/UserLocator.php',
'Flow\\OOUI\\BoardDescriptionWidget' => __DIR__ .
'/includes/OOUI/BoardDescriptionWidget.php',
'Flow\\OccupationController' => __DIR__ .
'/includes/TalkpageManager.php',
diff --git a/includes/Notifications/Formatter.php
b/includes/Notifications/Formatter.php
deleted file mode 100644
index 0f4535f..0000000
--- a/includes/Notifications/Formatter.php
+++ /dev/null
@@ -1,262 +0,0 @@
-<?php
-
-namespace Flow;
-
-use Flow\Exception\FlowException;
-use Flow\Model\Anchor;
-use Flow\Model\UUID;
-use Flow\Conversion\Utils;
-use Flow\Model\Workflow;
-use EchoBasicFormatter;
-use EchoEvent;
-use Message;
-use Title;
-use User;
-
-// could be renamed later if we have more formatters
-class NotificationFormatter extends EchoBasicFormatter {
- protected $urlGenerator;
-
- protected function processParam( $event, $param, $message, $user ) {
- $extra = $event->getExtra();
- if ( $param === 'subject' ) {
- if ( isset( $extra['topic-title'] ) &&
$extra['topic-title'] ) {
- $this->processParamEscaped( $message, trim(
$extra['topic-title'] ) );
- } else {
- $message->params( '' );
- }
- } elseif ( $param === 'commentText' ) {
- if ( isset( $extra['content'] ) && $extra['content'] ) {
- // @todo assumes content is html, make explicit
- $message->params( Utils::htmlToPlaintext(
$extra['content'], 200 ) );
- } else {
- $message->params( '' );
- }
- } elseif ( $param === 'post-permalink' ) {
- $anchor = $this->getPostLinkAnchor( $event, $user );
- if ( $anchor ) {
- $message->params( $anchor->getFullUrl() );
- } else {
- $message->params( '' );
- }
- } elseif ( $param === 'topic-permalink' ) {
- // link to individual new-topic
-
- if ( isset( $extra['topic-workflow'] ) ) {
- $title = Workflow::getFromTitleCache(
- wfWikiID(),
- NS_TOPIC,
-
$extra['topic-workflow']->getAlphadecimal()
- );
- } else {
- $title = $event->getTitle();
- }
-
- $anchor = $this->getUrlGenerator()->workflowLink(
$title, $extra['topic-workflow'] );
- $anchor->query['fromnotif'] = 1;
- $message->params( $anchor->getFullUrl() );
- } elseif ( $param === 'new-topics-permalink' ) {
- // link to board sorted by newest topics
- $title = $event->getTitle();
- if ( $title ) {
- $anchor = $this->getUrlGenerator()->boardLink(
$title, 'newest' );
- $anchor->query['fromnotif'] = 1;
- $message->params( $anchor->getFullUrl() );
- } else {
- $msg = 'Flow Formatter::' . __METHOD__ . ":
Param:" . $param . ' Echo event does not contain a title: ' . var_export(
$event, true );
- wfLogWarning( $msg );
- }
- } elseif ( $param == 'flow-title' ) {
- $title = $event->getTitle();
- if ( $title ) {
- $formatted = $this->formatTitle( $title );
- } else {
- $formatted = $this->getMessage( 'echo-no-title'
)->text();
- }
- $message->params( $formatted );
- } elseif ( $param == 'old-subject' ) {
- $this->processParamEscaped( $message, trim(
$extra['old-subject'] ) );
- } elseif ( $param == 'new-subject' ) {
- $this->processParamEscaped( $message, trim(
$extra['new-subject'] ) );
- } else {
- parent::processParam( $event, $param, $message, $user );
- }
- }
-
- /**
- * Helper method for generating a link to post notification
- * @param EchoEvent $event
- * @param User $user
- * @return Anchor|boolean
- * @throws FlowException
- */
- protected function getPostLinkAnchor( EchoEvent $event, User $user ) {
- $urlGenerator = $this->getUrlGenerator();
- $workflowId = $event->getExtraParam( 'topic-workflow' );
- if ( !$workflowId instanceof UUID ) {
- throw new FlowException( 'No topic-workflow available
for event ' . $event->getId() );
- }
-
- // Get topic title
- $title = Title::makeTitleSafe( NS_TOPIC,
$workflowId->getAlphadecimal() );
- $anchor = false;
- if ( $workflowId && $title ) {
- // Take user to the post if there is only one target
post,
- // otherwise, take user to the first unread post of
topic
- if ( $this->bundleData['raw-data-count'] <= 1 ) {
- $postId = $event->getExtraParam( 'post-id' );
- if ( !$postId instanceof UUID ) {
- // there's supposed to be a post-id but
there isn't
- // let's go to the first unread post
instead
- $postId = $this->getFirstUnreadPostId(
$event, $user );
- }
- $anchor = $urlGenerator->postLink( $title,
$workflowId, $postId );
- } else {
- $postId = $this->getFirstUnreadPostId( $event,
$user );
- if ( $postId ) {
- $anchor = $urlGenerator->postLink(
$title, $workflowId, $postId );
- } else {
- $anchor = $urlGenerator->topicLink(
$title, $workflowId );
- }
- }
- }
-
- $anchor->query['fromnotif'] = 1;
-
- return $anchor;
- }
-
- /**
- * Helper function for getLink()
- *
- * @param \EchoEvent $event
- * @param \User $user The user receiving the notification
- * @param string $destination The destination type for the link
- * @return array including target and query parameters
- * @throws FlowException
- */
- protected function getLinkParams( $event, $user, $destination ) {
- $anchor = null;
-
- // Unfortunately this is not a Flow code path, so we have to
reach
- // into global state.
- $urlGenerator = $this->getUrlGenerator();
-
- // Set up link parameters based on the destination (or pass to
parent)
- switch ( $destination ) {
- case 'flow-post':
- $anchor = $this->getPostLinkAnchor( $event,
$user );
- break;
-
- case 'flow-topic':
- $workflowId = $event->getExtraParam(
'topic-workflow' );
- if ( !$workflowId instanceof UUID ) {
- break;
- }
- // Get topic title
- $title = Title::makeTitleSafe( NS_TOPIC,
$workflowId->getAlphadecimal() );
- if ( $title ) {
- $anchor = $urlGenerator->topicLink(
$title, $workflowId );
- }
- break;
-
- case 'flow-new-topics':
- $title = $event->getTitle();
- if ( $title ) {
- $anchor = $urlGenerator->boardLink(
$title, 'newest' );
- }
- break;
-
- default:
- return parent::getLinkParams( $event, $user,
$destination );
- }
-
- if ( $anchor ) {
- $anchor->query['fromnotif'] = 1;
- return array( $anchor->resolveTitle(), $anchor->query );
- } else {
- return array( null, array() );
- }
- }
-
- /**
- * @return UrlGenerator
- */
- protected function getUrlGenerator() {
- if ( ! $this->urlGenerator ) {
- $this->urlGenerator = Container::get( 'url_generator' );
- }
-
- return $this->urlGenerator;
- }
-
- /**
- * Get the very first unread post from a topic in an event
- * @param \EchoEvent
- * @param \User
- * @return UUID|false
- */
- protected function getFirstUnreadPostId( $event, $user ) {
- $data = $this->getBundleLastRawData( $event, $user );
- if ( $data ) {
- // Remove the check once the corresponding Echo patch is
- // merged, $data should be always an instance of
EchoEvent
- if ( $data instanceof \EchoEvent ) {
- $extra = $data->getExtra();
- } elseif ( isset( $data->event_extra ) ) {
- $extra = $data->event_extra;
- }
- if ( isset( $extra['post-id'] ) ) {
- return $extra['post-id'];
- }
- }
-
- return false;
- }
-}
-
-/**
- * @FIXME - Move bundle iterator logic into a centralized place in Echo and
- * introduce bundle type param like 'agent', 'page', 'event' so child formatter
- * only needs to specify what iterator to use
- */
-class NewTopicFormatter extends NotificationFormatter {
- // Maximum topic count that is displayed exactly. Beyond this, it
shows +
- // to indicate there are more than that.
- const MAX_EXACT_TOPIC_COUNT = 99;
-
- /**
- * New Topic user 'event' as the iterator
- */
- protected function generateBundleData( $event, $user, $type ) {
- $data = $this->getRawBundleData( $event, $user, $type );
-
- if ( !$data ) {
- return;
- }
-
- // bundle event is excluding base event
- $this->bundleData['event-count'] = count( $data ) + 1;
- $this->bundleData['use-bundle'] =
$this->bundleData['event-count'] > 1;
- }
-
- /**
- * @param $event EchoEvent
- * @param $param string
- * @param $message Message
- * @param $user User
- */
- protected function processParam( $event, $param, $message, $user ) {
- switch ( $param ) {
- case 'event-count':
- $cappedCount = $this->bundleData['event-count']
<= self::MAX_EXACT_TOPIC_COUNT ?
- $this->bundleData['event-count'] :
- ( self::MAX_EXACT_TOPIC_COUNT + 1 );
- $message->numParams( $cappedCount );
- break;
- default:
- parent::processParam( $event, $param, $message,
$user );
- break;
- }
- }
-}
diff --git a/includes/Notifications/Notifications.php
b/includes/Notifications/Notifications.php
index d6ba7e9..214600c 100644
--- a/includes/Notifications/Notifications.php
+++ b/includes/Notifications/Notifications.php
@@ -3,33 +3,16 @@
$notificationTemplate = array(
'category' => 'flow-discussion',
'group' => 'other',
- 'formatter-class' => 'Flow\NotificationFormatter',
'immediate' => false, // Default
);
$newTopicNotification = array(
'presentation-model' => 'Flow\\NewTopicPresentationModel',
- 'formatter-class' => 'Flow\NewTopicFormatter',
- 'primary-link' => array(
- 'message' => 'flow-notification-link-text-view-topic',
- 'destination' => 'flow-new-topics'
- ),
- 'title-message' => 'flow-notification-newtopic',
- 'title-params' => array( 'agent', 'flow-title', 'title', 'subject',
'topic-permalink' ),
'bundle' => array(
'web' => true,
'email' => true,
'expandable' => true,
),
- 'bundle-type' => 'event',
- 'bundle-message' => 'flow-notification-newtopic-bundle',
- 'bundle-params' => array( 'event-count', 'title',
'new-topics-permalink' ),
- 'email-subject-message' => 'flow-notification-newtopic-email-subject',
- 'email-subject-params' => array( 'agent', 'title' ),
- 'email-body-batch-message' =>
'flow-notification-newtopic-email-batch-body',
- 'email-body-batch-params' => array( 'agent', 'subject', 'title' ),
- 'email-body-batch-bundle-message' =>
'flow-notification-newtopic-email-batch-bundle-body',
- 'email-body-batch-bundle-params' => array( 'event-count', 'title',
'new-topics-permalink' ),
'icon' => 'flow-new-topic'
) + $notificationTemplate;
@@ -39,65 +22,25 @@
'web' => true,
'email' => true,
),
- 'primary-link' => array(
- 'message' =>
'notification-links-flow-description-edited-view-page',
- 'destination' => 'title'
- ),
- 'title-message' => 'notification-header-flow-description-edited',
- 'title-params' => array( 'flow-title' ),
- 'email-subject-message' =>
'notification-email-subject-flow-description-edited',
- 'email-subject-params' => array( 'agent', 'title' ),
- 'email-body-batch-message' =>
'notification-email-batch-body-flow-description-edited',
- 'email-body-batch-params' => array( 'agent', 'title' ),
- 'email-body-batch-bundle-message' =>
'notification-email-batch-bundle-body-flow-description-edited',
- 'email-body-batch-bundle-params' => array( 'agent', 'title',
'agent-other-display', 'agent-other-count' ),
'icon' => 'flow-topic-renamed',
) + $notificationTemplate;
$postEditedNotification = array(
'presentation-model' => 'Flow\\PostEditedPresentationModel',
- 'primary-link' => array(
- 'message' => 'flow-notification-link-text-view-post',
- 'destination' => 'flow-post'
- ),
- 'title-message' => 'flow-notification-edit',
- 'title-params' => array( 'agent', 'subject', 'flow-title', 'title',
'post-permalink', 'topic-permalink' ),
'bundle' => array(
'web' => true,
'email' => true,
),
- 'bundle-message' => 'flow-notification-edit-bundle',
- 'bundle-params' => array( 'agent', 'subject', 'title',
'post-permalink', 'agent-other-display', 'agent-other-count' ),
- 'email-subject-message' => 'flow-notification-edit-email-subject',
- 'email-subject-params' => array( 'agent' ),
- 'email-body-batch-message' => 'flow-notification-edit-email-batch-body',
- 'email-body-batch-params' => array( 'agent', 'subject', 'title' ),
- 'email-body-batch-bundle-message' =>
'flow-notification-edit-email-batch-bundle-body',
- 'email-body-batch-bundle-params' => array( 'agent', 'subject', 'title',
'agent-other-display', 'agent-other-count' ),
'icon' => 'flow-post-edited',
) + $notificationTemplate;
$postReplyNotification = array(
'presentation-model' => 'Flow\\PostReplyPresentationModel',
- 'primary-link' => array(
- 'message' => 'flow-notification-link-text-view-post',
- 'destination' => 'flow-post'
- ),
- 'title-message' => 'flow-notification-reply',
- 'title-params' => array( 'agent', 'subject', 'flow-title', 'title',
'post-permalink' ),
'bundle' => array(
'web' => true,
'email' => true,
'expandable' => true,
),
- 'bundle-message' => 'flow-notification-reply-bundle',
- 'bundle-params' => array( 'agent', 'subject', 'title',
'post-permalink', 'agent-other-display', 'agent-other-count' ),
- 'email-subject-message' => 'flow-notification-reply-email-subject',
- 'email-subject-params' => array( 'agent', 'subject', 'title' ),
- 'email-body-batch-message' =>
'flow-notification-reply-email-batch-body',
- 'email-body-batch-params' => array( 'agent', 'subject', 'title' ),
- 'email-body-batch-bundle-message' =>
'flow-notification-reply-email-batch-bundle-body',
- 'email-body-batch-bundle-params' => array( 'agent', 'subject', 'title',
'agent-other-display', 'agent-other-count' ),
'icon' => 'chat',
) + $notificationTemplate;
--
To view, visit https://gerrit.wikimedia.org/r/300037
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie082588ca63f5df824fc5da65635339ec8b829e2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits