mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2026-10-22 23:12:12 +03:00
Add a basic validity check to savefile.js constructor
This commit is contained in:
1 parent
497e196d52
commit
827553a00c
1 file changed
+5
-1
@@ -66,7 +66,7 @@
|
||||
*/
|
||||
|
||||
var SAVEFILE = function(parsedObj){
|
||||
if (parsedObj){
|
||||
if (SAVEFILE.isValid(parsedObj)){
|
||||
this.meta = parsedObj.meta;
|
||||
this.meta.users = this.meta.users || {};
|
||||
this.meta.userindex = this.meta.userindex || [];
|
||||
@@ -89,6 +89,10 @@ var SAVEFILE = function(parsedObj){
|
||||
this.tmp.userlookup = {};
|
||||
};
|
||||
|
||||
SAVEFILE.isValid = function(parsedObj){
|
||||
return parsedObj && typeof parsedObj.meta === "object" && typeof parsedObj.data === "object";
|
||||
};
|
||||
|
||||
SAVEFILE.prototype.findOrRegisterUser = function(userId, userName){
|
||||
if (!(userId in this.meta.users)){
|
||||
this.meta.users[userId] = {
|
||||
|
||||
Reference in new issue
Block a user