Hard depend upon Echo in extension.json

This extension is useless without Echo, and the API modules already
disable themselves if it's not installed. Just absolutely require Echo
to be installed.

Change-Id: I653eea78668bfe0875bc5a33e2d45607106d4ee5
This commit is contained in:
Kunal Mehta 2018-04-11 01:00:30 -07:00
parent 2e17710561
commit b8b892bb98
7 changed files with 11 additions and 24 deletions

View file

@ -10,6 +10,11 @@
"descriptionmsg": "thanks-desc",
"license-name": "MIT",
"type": "other",
"requires": {
"extensions": {
"Echo": "*"
}
},
"DefaultUserOptions": {
"echo-subscriptions-web-edit-thank": true,
"echo-subscriptions-email-edit-thank": false

View file

@ -19,7 +19,6 @@
"thanks-error-invalidrecipient": "No valid recipient found",
"thanks-error-invalidrecipient-bot": "Bots cannot be thanked",
"thanks-error-invalidrecipient-self": "You cannot thank yourself",
"thanks-error-echonotinstalled": "Echo is not installed on this wiki",
"thanks-error-notloggedin": "Anonymous users cannot send thanks",
"thanks-error-ratelimited": "{{GENDER:$1|You}}'ve exceeded your rate limit. Please wait some time and try again.",
"thanks-error-api-params": "Either the 'revid' or the 'logid' parameter must be provided",

View file

@ -30,7 +30,6 @@
"thanks-error-invalidrecipient": "Error message that is displayed when no recipient is found",
"thanks-error-invalidrecipient-bot": "Error message that is displayed when the recipient is a bot",
"thanks-error-invalidrecipient-self": "Error message that is displayed when the recipient is the user doing the thanking",
"thanks-error-echonotinstalled": "Error message that is displayed when Echo is not installed",
"thanks-error-notloggedin": "Error message that is displayed when the user is not logged in",
"thanks-error-ratelimited": "Error message that is displayed when user exceeds rate limit.\n\nParameters:\n* $1 - The user sending the thanks. Can be used for GENDER support.",
"thanks-error-api-params": "Error message shown when both the 'rev' and 'log' API parameters are absent",

View file

@ -13,7 +13,6 @@ class ApiCoreThank extends ApiThank {
*/
public function execute() {
// Initial setup.
$this->dieIfEchoNotInstalled();
$user = $this->getUser();
$this->dieOnBadUser( $user );
$params = $this->extractRequestParams();

View file

@ -17,8 +17,6 @@ use Flow\Model\UUID;
class ApiFlowThank extends ApiThank {
public function execute() {
$this->dieIfEchoNotInstalled();
$user = $this->getUser();
$this->dieOnBadUser( $user );

View file

@ -6,12 +6,6 @@
* @ingroup Extensions
*/
abstract class ApiThank extends ApiBase {
protected function dieIfEchoNotInstalled() {
if ( !class_exists( 'EchoNotifier' ) ) {
$this->dieWithError( 'thanks-error-echonotinstalled', 'echonotinstalled' );
}
}
protected function dieOnBadUser( User $user ) {
if ( $user->isAnon() ) {
$this->dieWithError( 'thanks-error-notloggedin', 'notloggedin' );

View file

@ -47,13 +47,11 @@ class ThanksHooks {
public static function insertThankLink( $rev, &$links, $oldRev, User $user ) {
$recipientId = $rev->getUser();
$recipient = User::newFromId( $recipientId );
// Make sure Echo is turned on.
// Don't let users thank themselves.
// Exclude anonymous users.
// Exclude users who are blocked.
// Check whether bots are allowed to receive thanks.
if ( class_exists( 'EchoNotifier' )
&& !$user->isAnon()
if ( !$user->isAnon()
&& $recipientId !== $user->getId()
&& !$user->isBlocked()
&& self::canReceiveThanks( $recipient )
@ -146,9 +144,7 @@ class ThanksHooks {
* @return bool true in all cases
*/
public static function onPageHistoryBeforeList( &$page, $context ) {
if ( class_exists( 'EchoNotifier' )
&& $context->getUser()->isLoggedIn()
) {
if ( $context->getUser()->isLoggedIn() ) {
static::addThanksModule( $context->getOutput() );
}
return true;
@ -163,9 +159,7 @@ class ThanksHooks {
* @return bool true in all cases
*/
public static function onDiffViewHeader( $diff, $oldRev, $newRev ) {
if ( class_exists( 'EchoNotifier' )
&& $diff->getUser()->isLoggedIn()
) {
if ( $diff->getUser()->isLoggedIn() ) {
static::addThanksModule( $diff->getOutput() );
}
return true;
@ -270,10 +264,9 @@ class ThanksHooks {
public static function onBeforeSpecialMobileDiffDisplay( &$output, $ctx, $revisions ) {
$rev = $revisions[1];
// If the Echo and MobileFrontend extensions are installed and the user is
// If the MobileFrontend extension is installed and the user is
// logged in or recipient is not a bot if bots cannot receive thanks, show a 'Thank' link.
if ( $rev
&& class_exists( 'EchoNotifier' )
&& class_exists( 'SpecialMobileDiff' )
&& self::canReceiveThanks( User::newFromId( $rev->getUser() ) )
&& $output->getUser()->isLoggedIn()
@ -386,8 +379,8 @@ class ThanksHooks {
) {
global $wgUser;
// Don't thank if anonymous or Echo is not installed.
if ( !class_exists( 'EchoNotifier' ) || $wgUser->isAnon() || $wgUser->isBlocked() ) {
// Don't thank if anonymous or blocked
if ( $wgUser->isAnon() || $wgUser->isBlocked() ) {
return;
}