Skip to content

Commit

Permalink
Use -1 instead of 0 for new entries
Browse files Browse the repository at this point in the history
Preventing a potential risk of having 0 as the first ever entry, while -1 have a meaning of none
  • Loading branch information
Hans5958 committed Jun 20, 2023
1 parent c38cf61 commit f1fa8a1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion tools/atlas.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
4 changes: 2 additions & 2 deletions tools/redditcrawl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
2 changes: 1 addition & 1 deletion web/_js/main/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function initDraw() {

function generateExportObject() {
const exportObject = {
id: entryId ?? 0,
id: entryId ?? -1,
name: nameField.value,
description: descriptionField.value,
links: {},
Expand Down

0 comments on commit f1fa8a1

Please sign in to comment.