From f1fa8a104f34d610d8cd5e4e387865e51b6a5d6f Mon Sep 17 00:00:00 2001 From: Hans5958 Date: Tue, 25 Apr 2023 13:42:18 +0700 Subject: [PATCH] Use -1 instead of 0 for new entries Preventing a potential risk of having 0 as the first ever entry, while -1 have a meaning of none --- tools/atlas.schema.json | 3 ++- tools/redditcrawl.py | 4 ++-- web/_js/main/draw.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/atlas.schema.json b/tools/atlas.schema.json index e2d9aa040..cf4f764de 100644 --- a/tools/atlas.schema.json +++ b/tools/atlas.schema.json @@ -10,7 +10,8 @@ "type": "string" }, { - "type": "integer" + "type": "integer", + "minimum": 0 } ], "description": "The ID of the entry. Usually this is the post ID of the new entry submission." diff --git a/tools/redditcrawl.py b/tools/redditcrawl.py index 9f5a4103f..f64f1cb7b 100755 --- a/tools/redditcrawl.py +++ b/tools/redditcrawl.py @@ -103,13 +103,13 @@ def set_flair(submission, flair): if submission.link_flair_text == "Edit Entry": - assert submission_json["id"] != 0, "Edit invalid because ID is tampered, it must not be 0!" + assert submission_json["id"] > 0, "Edit invalid because ID is tampered, it must not be 0 or -1!" submission_json_dummy = {"id": submission_json["id"], "edit": submission.id} else: - assert submission_json["id"] == 0, "Edit invalid because ID is tampered, it must be 0!" + assert submission_json["id"] <= 0, "Addition invalid because ID is tampered, it must be 0 or -1!" submission_json_dummy = {"id": submission.id} diff --git a/web/_js/main/draw.js b/web/_js/main/draw.js index 5cc07c077..cd1c0763d 100644 --- a/web/_js/main/draw.js +++ b/web/_js/main/draw.js @@ -260,7 +260,7 @@ function initDraw() { function generateExportObject() { const exportObject = { - id: entryId ?? 0, + id: entryId ?? -1, name: nameField.value, description: descriptionField.value, links: {},