mediawiki-extensions-Echo/modules/api/mw.echo.api.ForeignAPIHandler.js
Moriel Schottlender 820d2b0fa7 Add a cross-wiki sidebar to the Special:Notifications page
Add a sidebar with cross-wiki sources and pages of unread notifications.
The filter allows the user to fetch notifications from a foreign source
and specific pages if those exist.

Bug: T129366
Change-Id: I57d827a47f80274d75364c2099a9624049a26834
2016-06-21 14:49:42 -07:00

45 lines
1.1 KiB
JavaScript

( function ( mw, $ ) {
/**
* 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
* @cfg {boolean} [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.parent.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 ) {
var params = {
// Backwards compatibility
notforn: 1
};
if ( this.unreadOnly ) {
params = $.extend( {}, params, { notfilter: '!read' } );
}
return $.extend( {}, this.typeParams[ type ], params );
};
} )( mediaWiki, jQuery );