mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-11 15:38:37 +00:00
e27f4937ff
Allows users to send notifications to themselves (T306211). For sending notifications to others, a new permission is created (echo-create), assigned only to bots by default. For now, only one user can be notified in one API request. If the email flag is set in the API params, the notification is also sent as an email, provided the user hasn't disabled email notifications for the "api-triggered" category. This feature is behind a feature flag. Set $wgEchoEnableApiEvents = true to use. Adapted from If0267a38be7d454e3d284d30f93c93a828288dd7. Co-authored-by: TheresNoTime <starling-ctr@wikimedia.org> Bug: T58362 Bug: T306211 Change-Id: I94642bff5dcb075cb9db862206d59c19edad9fd1
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Notifications\Formatters;
|
|
|
|
class EchoManualPresentationModel extends EchoEventPresentationModel {
|
|
|
|
/** @inheritDoc */
|
|
public function getIconType() {
|
|
return 'robot';
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
public function getHeaderMessage() {
|
|
return $this->msg( 'notification-header-api-triggered' )
|
|
->plaintextParams( $this->event->getExtraParam( 'header' ), $this->event->getAgent()->getName() );
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
public function getSubjectMessage() {
|
|
return $this->getHeaderMessage();
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
public function getPrimaryLink() {
|
|
if ( !$this->event->getTitle() ) {
|
|
return false;
|
|
}
|
|
return [
|
|
'url' => $this->event->getTitle()->getLocalURL(),
|
|
'label' => $this->msg( 'notification-link-api-triggered' )->text(),
|
|
];
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
public function getBodyMessage() {
|
|
$content = $this->event->getExtraParam( 'content' );
|
|
|
|
// Content here passed through plaintextParams for sanitization
|
|
return $content ? $this->msg( 'notification-body-api-triggered' )->plaintextParams( $content ) : false;
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
public function getSecondaryLinks() {
|
|
$agentLink = $this->getAgentLink();
|
|
$agentLink['tooltip'] = $this->msg( 'notification-tooltip-api-triggered',
|
|
$this->event->getAgent()->getName() );
|
|
return [
|
|
$agentLink
|
|
];
|
|
}
|
|
}
|