mediawiki-extensions-Echo/modules/api/mw.echo.api.ForeignAPIHandler.js
Ed Sanders 1d3be2c605 ESLint: Autofix no-var errors
Keep the rule and prefer-const disabled as they will
require manual fixing.

Change-Id: Idd31eb7d7a456b10c07b905b4b837dd4c890eb71
2024-06-03 13:22:48 +01:00

45 lines
1.1 KiB
JavaScript

( function () {
/**
* Foreign notification API handler
*
* @class
* @extends mw.echo.api.LocalAPIHandler
*
* @constructor
* @param {string} apiUrl A url for the access point of the
* foreign API.
* @param {Object} [config] Configuration object
* @param {boolean} [config.unreadOnly] Whether this handler should request unread
* notifications by default.
*/
mw.echo.api.ForeignAPIHandler = function MwEchoApiForeignAPIHandler( apiUrl, config ) {
config = config || {};
// Parent constructor
mw.echo.api.ForeignAPIHandler.super.call( this, config );
this.api = new mw.ForeignApi( apiUrl );
this.unreadOnly = config.unreadOnly !== undefined ? !!config.unreadOnly : false;
};
/* Setup */
OO.inheritClass( mw.echo.api.ForeignAPIHandler, mw.echo.api.LocalAPIHandler );
/**
* @inheritdoc
*/
mw.echo.api.ForeignAPIHandler.prototype.getTypeParams = function ( type ) {
let params = {
// Backwards compatibility
notforn: 1
};
if ( this.unreadOnly ) {
params = $.extend( {}, params, { notfilter: '!read' } );
}
return $.extend( {}, this.typeParams[ type ], params );
};
}() );