mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 01:35:28 +01:00
Check for valid uuid
This commit is contained in:
parent
f03e8d48a2
commit
9d870f0611
@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
|
import uuid
|
||||||
from jsonschema import ValidationError, validate
|
from jsonschema import ValidationError, validate
|
||||||
from app.classes.web.base_api_handler import BaseApiHandler
|
from app.classes.web.base_api_handler import BaseApiHandler
|
||||||
|
|
||||||
@ -92,7 +93,11 @@ class ApiAnnounceIndexHandler(BaseApiHandler):
|
|||||||
for item in cleared_notifs[:]:
|
for item in cleared_notifs[:]:
|
||||||
if item not in res:
|
if item not in res:
|
||||||
cleared_notifs.remove(item)
|
cleared_notifs.remove(item)
|
||||||
cleared_notifs.append(data["id"])
|
if is_valid_uuid(data["id"]):
|
||||||
|
cleared_notifs.append(data["id"])
|
||||||
|
else:
|
||||||
|
self.finish_json(200, {"status": "error", "error": "INVALID_DATA"})
|
||||||
|
return
|
||||||
updata = {"cleared_notifs": ",".join(cleared_notifs)}
|
updata = {"cleared_notifs": ",".join(cleared_notifs)}
|
||||||
self.controller.users.update_user(auth_data[4]["user_id"], updata)
|
self.controller.users.update_user(auth_data[4]["user_id"], updata)
|
||||||
self.finish_json(
|
self.finish_json(
|
||||||
@ -102,3 +107,12 @@ class ApiAnnounceIndexHandler(BaseApiHandler):
|
|||||||
"data": {},
|
"data": {},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def is_valid_uuid(value):
|
||||||
|
try:
|
||||||
|
uuid.UUID(str(value))
|
||||||
|
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user