diff --git a/myems-api/MyEMS.postman_collection.json b/myems-api/MyEMS.postman_collection.json index ffabe142..3fa925ce 100644 --- a/myems-api/MyEMS.postman_collection.json +++ b/myems-api/MyEMS.postman_collection.json @@ -9655,6 +9655,74 @@ }, "response": [] }, + { + "name": "PUT Update All New Web Messages (Mark All As Read)", + "request": { + "method": "PUT", + "header": [ + { + "key": "User-UUID", + "value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4", + "type": "text", + "description": "Any admin users' UUID" + }, + { + "key": "Token", + "value": "597881540b33791a032b95aa48e0de098dc95ec0b813edd8a92cee87ee5eed1b8db7856a047ed06324c333bf2c98f0c7613e346ae25d1bcae3994f30b4562dfb", + "type": "text", + "description": "Login to get a valid token" + } + ], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"status\":\"read\"}}" + }, + "url": { + "raw": "{{base_url}}/webmessagesnew", + "host": [ + "{{base_url}}" + ], + "path": [ + "webmessagesnew" + ] + } + }, + "response": [] + }, + { + "name": "PUT Update All New Web Messages (Acknowledge All)", + "request": { + "method": "PUT", + "header": [ + { + "key": "User-UUID", + "value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4", + "type": "text", + "description": "Any admin users' UUID" + }, + { + "key": "Token", + "value": "597881540b33791a032b95aa48e0de098dc95ec0b813edd8a92cee87ee5eed1b8db7856a047ed06324c333bf2c98f0c7613e346ae25d1bcae3994f30b4562dfb", + "type": "text", + "description": "Login to get a valid token" + } + ], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"status\":\"acknowledged\", \"reply\":\"OK\"}}" + }, + "url": { + "raw": "{{base_url}}/webmessagesnew", + "host": [ + "{{base_url}}" + ], + "path": [ + "webmessagesnew" + ] + } + }, + "response": [] + }, { "name": "GET a Web Message by ID", "request": { diff --git a/myems-api/core/webmessage.py b/myems-api/core/webmessage.py index ac75d902..6475495a 100644 --- a/myems-api/core/webmessage.py +++ b/myems-api/core/webmessage.py @@ -265,13 +265,13 @@ class WebMessageStatusNewCollection: status = str.strip(new_values['data']['status']) # reply is required for 'acknowledged' status - if status == 'acknowledged' and \ - ('reply' not in new_values['data'].keys() or - not isinstance(new_values['data']['reply'], str) or - len(str.strip(new_values['data']['reply'])) == 0): - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_REPLY') - reply = str.strip(new_values['data']['reply']) + if status == 'acknowledged': + if 'reply' not in new_values['data'].keys() or \ + not isinstance(new_values['data']['reply'], str) or \ + len(str.strip(new_values['data']['reply'])) == 0: + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_REPLY') + else: + reply = str.strip(new_values['data']['reply']) else: reply = None @@ -485,13 +485,13 @@ class WebMessageItem: status = str.strip(new_values['data']['status']) # reply is required for 'acknowledged' status - if status == 'acknowledged' and \ - ('reply' not in new_values['data'].keys() or - not isinstance(new_values['data']['reply'], str) or - len(str.strip(new_values['data']['reply'])) == 0): - raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', - description='API.INVALID_REPLY') - reply = str.strip(new_values['data']['reply']) + if status == 'acknowledged': + if 'reply' not in new_values['data'].keys() or \ + not isinstance(new_values['data']['reply'], str) or \ + len(str.strip(new_values['data']['reply'])) == 0: + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_REPLY') + else: + reply = str.strip(new_values['data']['reply']) else: reply = None