This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12147 from gabrielesvelto/bug-887156-wappush-whit…
…elist Bug 887156 - Add a mechanism to filter WAP Push messages based on a whitelist of source MSISDNs r=timdream
- Loading branch information
Showing
5 changed files
with
95 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
js/whitelist.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / | ||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* MSISDN whitelist, if not empty only the messages sent from the MSISDNs | ||
* present in the list will be shown to the user, others will be discarded. | ||
*/ | ||
var WhiteList = { | ||
/** An array holding the list of MSISDNs */ | ||
_whiteList: [], | ||
|
||
/** | ||
* Read the whitelist.json file from disk and initialize the whitelist with | ||
* it. If the file is not present or empty the whitelist will be empty. | ||
*/ | ||
init: function wl_init() { | ||
var xhr = new XMLHttpRequest(); | ||
xhr.overrideMimeType('application/json'); | ||
xhr.open('GET', 'js/whitelist.json', true); | ||
xhr.send(null); | ||
|
||
xhr.onreadystatechange = (function wl_load(evt) { | ||
if (xhr.readyState != 4) | ||
return; | ||
|
||
if (xhr.status == 0 || xhr.status == 200) { | ||
var list = JSON.parse(xhr.responseText); | ||
var whiteList = []; | ||
|
||
list.forEach(function wl_addTo(item) { | ||
whiteList.push(item); | ||
}); | ||
|
||
this._whiteList = whiteList; | ||
} | ||
}).bind(this); | ||
}, | ||
|
||
/** | ||
* Checks if the element is in the whitelist. | ||
* | ||
* @return {Boolean} true if the element is in the whitelist, always return | ||
* true if the whitelist is empty | ||
*/ | ||
has: function wl_has(value) { | ||
if (this._whiteList.length === 0) { | ||
return true; | ||
} | ||
|
||
return (this._whiteList.indexOf(value) !== -1); | ||
} | ||
}; | ||
|
||
WhiteList.init(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.