Debian Codegraph @

extensions/Echo/modules/api/mw.echo.api.ForeignAPIHandler.js

raw symbols SCIP
1 ( function () {
2 /**
3 * Foreign notification API handler
4 *
5 * @class
6 * @extends mw.echo.api.LocalAPIHandler
7 *
8 * @constructor
9 * @param {string} apiUrl A url for the access point of the
10 * foreign API.
11 * @param {Object} [config] Configuration object
12 * @param {boolean} [config.unreadOnly] Whether this handler should request unread
13 * notifications by default.
14 */
15 mw.echo.api.ForeignAPIHandler = function MwEchoApiForeignAPIHandler( apiUrl, config ) {
16 config = config || {};
17
18 // Parent constructor
19 mw.echo.api.ForeignAPIHandler.super.call( this, config );
20
21 this.api = new mw.ForeignApi( apiUrl );
22 this.unreadOnly = config.unreadOnly !== undefined ? !!config.unreadOnly : false;
23 };
24
25 /* Setup */
26
27 OO.inheritClass( mw.echo.api.ForeignAPIHandler, mw.echo.api.LocalAPIHandler );
28
29 /**
30 * @inheritdoc
31 */
32 mw.echo.api.ForeignAPIHandler.prototype.getTypeParams = function ( type ) {
33 let params = {
34 // Backwards compatibility
35 notforn: 1
36 };
37
38 if ( this.unreadOnly ) {
39 params = Object.assign( {}, params, { notfilter: '!read' } );
40 }
41
42 return Object.assign( {}, this.typeParams[ type ], params );
43 };
44 }() );