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
This commit is contained in:
Hans5958 2023-04-25 13:42:18 +07:00
parent c38cf611cd
commit f1fa8a104f
3 changed files with 5 additions and 4 deletions

View file

@ -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."

View file

@ -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}

View file

@ -260,7 +260,7 @@ function initDraw() {
function generateExportObject() {
const exportObject = {
id: entryId ?? 0,
id: entryId ?? -1,
name: nameField.value,
description: descriptionField.value,
links: {},