mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-04-13 15:27:16 +03:00
Add a basic validity check to savefile.js constructor
This commit is contained in:
parent
497e196d52
commit
827553a00c
@ -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] = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user