2018-11-12 13:56:38 +00:00
|
|
|
( function () {
|
2016-01-15 22:11:33 +00:00
|
|
|
/**
|
|
|
|
* 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
|
2024-05-27 01:43:21 +00:00
|
|
|
* @param {boolean} [config.unreadOnly] Whether this handler should request unread
|
2016-05-31 22:32:16 +00:00
|
|
|
* notifications by default.
|
2016-01-15 22:11:33 +00:00
|
|
|
*/
|
|
|
|
mw.echo.api.ForeignAPIHandler = function MwEchoApiForeignAPIHandler( apiUrl, config ) {
|
|
|
|
config = config || {};
|
|
|
|
|
|
|
|
// Parent constructor
|
2018-05-22 14:56:46 +00:00
|
|
|
mw.echo.api.ForeignAPIHandler.super.call( this, config );
|
2016-01-15 22:11:33 +00:00
|
|
|
|
|
|
|
this.api = new mw.ForeignApi( apiUrl );
|
2016-05-31 22:32:16 +00:00
|
|
|
this.unreadOnly = config.unreadOnly !== undefined ? !!config.unreadOnly : false;
|
2016-01-15 22:11:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Setup */
|
|
|
|
|
|
|
|
OO.inheritClass( mw.echo.api.ForeignAPIHandler, mw.echo.api.LocalAPIHandler );
|
2016-04-21 10:28:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
mw.echo.api.ForeignAPIHandler.prototype.getTypeParams = function ( type ) {
|
2024-06-03 12:22:48 +00:00
|
|
|
let params = {
|
2016-04-26 22:55:07 +00:00
|
|
|
// Backwards compatibility
|
2016-05-31 22:32:16 +00:00
|
|
|
notforn: 1
|
|
|
|
};
|
|
|
|
|
|
|
|
if ( this.unreadOnly ) {
|
|
|
|
params = $.extend( {}, params, { notfilter: '!read' } );
|
|
|
|
}
|
|
|
|
|
|
|
|
return $.extend( {}, this.typeParams[ type ], params );
|
2016-04-21 10:28:32 +00:00
|
|
|
};
|
2018-11-12 13:56:38 +00:00
|
|
|
}() );
|