diff --git a/customiwmserver/database.py b/customiwmserver/database.py index fb66fdd..b790674 100644 --- a/customiwmserver/database.py +++ b/customiwmserver/database.py @@ -47,3 +47,8 @@ def auth_check(Authorization): return False, "wrongpass" return True, query + + + +def id_to_mapcode(id_): + return hex(id_).replace("0x", "").rjust(8, "0")[0:8].upper() diff --git a/customiwmserver/main.py b/customiwmserver/main.py index 0b99bd2..53f1bc6 100644 --- a/customiwmserver/main.py +++ b/customiwmserver/main.py @@ -277,13 +277,14 @@ async def upload_map( elif authcheck[0]: print(authcheck) userData = types.User(**authcheck[1]) - MapCode = "SUSYBAKA" # FIXME Add mapcodes correctly + ID = len(list(db.maps_collection.find({}))) + 1 + MapCode = db.id_to_mapcode(ID) # FIXME Add mapcodes correctly db.maps_collection.insert_one( { **types.Map( CreatorName=userData.Username, CreatorId=userData.ID, - ID=len(list(db.maps_collection.find({}))) + 1, + ID=ID, Name=mapName, Description=mapDescription, Version=mapVersion,