2021-04-30 16:07:31 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Our override of the built-in Echo presentation model for user talk page notifications.
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
|
|
|
* @license MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Notifications;
|
|
|
|
|
2024-05-28 14:46:27 +00:00
|
|
|
use MediaWiki\Extension\Notifications\Formatters\EchoEditUserTalkPresentationModel;
|
2023-05-19 10:30:50 +00:00
|
|
|
use MediaWiki\Language\RawMessage;
|
2024-06-08 22:02:35 +00:00
|
|
|
use MediaWiki\Message\Message;
|
2022-10-28 18:24:02 +00:00
|
|
|
use Wikimedia\Timestamp\TimestampException;
|
2021-04-30 16:07:31 +00:00
|
|
|
|
|
|
|
class EnhancedEchoEditUserTalkPresentationModel extends EchoEditUserTalkPresentationModel {
|
|
|
|
|
|
|
|
use DiscussionToolsEventTrait;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getPrimaryLink() {
|
|
|
|
$linkInfo = parent::getPrimaryLink();
|
|
|
|
// For events enhanced by DiscussionTools: link to the individual comment
|
|
|
|
$link = $this->getCommentLink();
|
|
|
|
if ( $link ) {
|
|
|
|
$linkInfo['url'] = $link;
|
|
|
|
}
|
|
|
|
return $linkInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getBodyMessage() {
|
|
|
|
if ( !$this->isBundled() ) {
|
|
|
|
// For events enhanced by DiscussionTools: add a text snippet
|
|
|
|
// (Echo can only do this for new sections, not for every comment)
|
|
|
|
$snippet = $this->getContentSnippet();
|
|
|
|
if ( $snippet ) {
|
|
|
|
return new RawMessage( '$1', [ Message::plaintextParam( $snippet ) ] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return parent::getBodyMessage();
|
|
|
|
}
|
2021-12-09 00:13:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
2022-10-28 18:24:02 +00:00
|
|
|
* @throws TimestampException
|
2021-12-09 00:13:21 +00:00
|
|
|
*/
|
2022-07-02 15:36:39 +00:00
|
|
|
public function jsonSerialize(): array {
|
2021-12-09 00:13:21 +00:00
|
|
|
$array = parent::jsonSerialize();
|
|
|
|
|
|
|
|
$array['links']['legacyPrimary'] = $this->addMarkAsRead( parent::getPrimaryLink() ) ?: [];
|
|
|
|
|
|
|
|
return $array;
|
|
|
|
}
|
2021-04-30 16:07:31 +00:00
|
|
|
}
|