updated Web Message actions in API and Notification Page in Web UI
parent
12843792f1
commit
1e652da94d
|
@ -2144,21 +2144,45 @@ Result in JSON
|
||||||
| message | string | Web Message Body |
|
| message | string | Web Message Body |
|
||||||
| created_datetime| float | Web Message Created Datetime (POSIX timestamp * 1000)|
|
| created_datetime| float | Web Message Created Datetime (POSIX timestamp * 1000)|
|
||||||
| status | string | Status ('new', 'acknowledged', 'timeout') |
|
| status | string | Status ('new', 'acknowledged', 'timeout') |
|
||||||
| reply | string | User's Reply text, allow null |
|
| reply | string | User's Reply text, required for 'acknowledged' status, otherwise allow null |
|
||||||
```bash
|
```bash
|
||||||
curl -i -H "User-UUID: 793f1bb4-6e25-4242-8cdc-2f662b25484f" -H "Token: GET-TOKEN-AFTER-LOGIN" -X GET {{base_url}}/webmessages/{id}
|
curl --location --request GET '{{base_url}}/webmessages/{id}' \
|
||||||
|
--header 'User-UUID: dcdb67d1-6116-4987-916f-6fc6cf2bc0e4' \
|
||||||
|
--header 'Token: 24bb236244f26784fb1397344d926b4871e87a90096eae926a0e448396dbd3ff4a2f70f727089f025238cb47bdbccdc877ef4a50fad8f05a4e5100c5d3eb0d3c'
|
||||||
```
|
```
|
||||||
* GET Web Messages by Datetime Range
|
* GET Web Messages by Datetime Range
|
||||||
```bash
|
```bash
|
||||||
curl -i -H "User-UUID: 793f1bb4-6e25-4242-8cdc-2f662b25484f" -H "Token: GET-TOKEN-AFTER-LOGIN" -X GET {{base_url}}/webmessages?startdatetime={startdatetime}&enddatetime={enddatetime}
|
curl --location --request GET '{{base_url}}/webmessages?startdatetime=2021-12-11T00:00:00&enddatetime=2021-12-21T00:00:00' \
|
||||||
|
--header 'User-UUID: dcdb67d1-6116-4987-916f-6fc6cf2bc0e4' \
|
||||||
|
--header 'Token: 9ac434f394c735092cfeb083612e533ca33ca6db4815ebb0c3ff47896d7eaa610e7dc312c04279253f817d65d1ef379378d4a5d07150faee5f6d899adb8b7ca7'
|
||||||
```
|
```
|
||||||
* GET New Web Messages
|
* GET New Web Messages
|
||||||
```bash
|
```bash
|
||||||
curl -i -H "User-UUID: 793f1bb4-6e25-4242-8cdc-2f662b25484f" -H "Token: GET-TOKEN-AFTER-LOGIN" -X GET {{base_url}}/webmessagesnew
|
curl --location --request GET '{{base_url}}/webmessagesnew' \
|
||||||
|
--header 'User-UUID: dcdb67d1-6116-4987-916f-6fc6cf2bc0e4' \
|
||||||
|
--header 'Token: 9bcd171e4f4169f1f45791aeadc8f90cfe8694be92f21af7bf95673f8cc910ca7a91bfd4a577d48d0720155de497eb02baab614be5c6c83891f1a856f9cf666a'
|
||||||
|
```
|
||||||
|
* PUT Update a Web Message (Acknowledge)
|
||||||
|
```bash
|
||||||
|
curl --location --request PUT '{{base_url}}/webmessages/{id}' \
|
||||||
|
--header 'User-UUID: dcdb67d1-6116-4987-916f-6fc6cf2bc0e4' \
|
||||||
|
--header 'Token: 9bcd171e4f4169f1f45791aeadc8f90cfe8694be92f21af7bf95673f8cc910ca7a91bfd4a577d48d0720155de497eb02baab614be5c6c83891f1a856f9cf666a' \
|
||||||
|
--header 'Content-Type: text/plain' \
|
||||||
|
--data-raw '{"data":{"status":"acknowledged", "reply":"this is my reply"}}'
|
||||||
|
```
|
||||||
|
* PUT Update a Web Message (Mark As Read)
|
||||||
|
```bash
|
||||||
|
curl --location --request PUT '{{base_url}}/webmessages/{id}' \
|
||||||
|
--header 'User-UUID: dcdb67d1-6116-4987-916f-6fc6cf2bc0e4' \
|
||||||
|
--header 'Token: 9bcd171e4f4169f1f45791aeadc8f90cfe8694be92f21af7bf95673f8cc910ca7a91bfd4a577d48d0720155de497eb02baab614be5c6c83891f1a856f9cf666a' \
|
||||||
|
--header 'Content-Type: text/plain' \
|
||||||
|
--data-raw '{"data":{"status":"read"}}'
|
||||||
```
|
```
|
||||||
* DELETE a Web Message by ID
|
* DELETE a Web Message by ID
|
||||||
```bash
|
```bash
|
||||||
curl -i -H "User-UUID: 793f1bb4-6e25-4242-8cdc-2f662b25484f" -H "Token: GET-TOKEN-AFTER-LOGIN" -X DELETE {{base_url}}/webmessages/{id}
|
curl --location --request DELETE '{{base_url}}/webmessages/{id}' \
|
||||||
|
--header 'User-UUID: dcdb67d1-6116-4987-916f-6fc6cf2bc0e4' \
|
||||||
|
--header 'Token: 24bb236244f26784fb1397344d926b4871e87a90096eae926a0e448396dbd3ff4a2f70f727089f025238cb47bdbccdc877ef4a50fad8f05a4e5100c5d3eb0d3c'
|
||||||
```
|
```
|
||||||
|
|
||||||
### Wechat Message
|
### Wechat Message
|
||||||
|
|
|
@ -367,17 +367,21 @@ class WebMessageItem:
|
||||||
if 'status' not in new_values['data'].keys() or \
|
if 'status' not in new_values['data'].keys() or \
|
||||||
not isinstance(new_values['data']['status'], str) or \
|
not isinstance(new_values['data']['status'], str) or \
|
||||||
len(str.strip(new_values['data']['status'])) == 0 or \
|
len(str.strip(new_values['data']['status'])) == 0 or \
|
||||||
str.strip(new_values['data']['status']) not in ('new', 'acknowledged', 'timeout', 'read'):
|
str.strip(new_values['data']['status']) not in ('new', 'acknowledged', 'read'):
|
||||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.INVALID_STATUS')
|
description='API.INVALID_STATUS')
|
||||||
status = str.strip(new_values['data']['status'])
|
status = str.strip(new_values['data']['status'])
|
||||||
|
|
||||||
if 'reply' not in new_values['data'].keys() or \
|
# reply is required for 'acknowledged' status
|
||||||
not isinstance(new_values['data']['reply'], str) or \
|
if status == 'acknowledged' and \
|
||||||
len(str.strip(new_values['data']['reply'])) == 0:
|
('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',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.INVALID_REPLY')
|
description='API.INVALID_REPLY')
|
||||||
reply = str.strip(new_values['data']['reply'])
|
reply = str.strip(new_values['data']['reply'])
|
||||||
|
else:
|
||||||
|
reply = None
|
||||||
|
|
||||||
# Verify User Session
|
# Verify User Session
|
||||||
token = req.headers.get('TOKEN')
|
token = req.headers.get('TOKEN')
|
||||||
|
|
|
@ -260,8 +260,7 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
"data": {
|
"data": {
|
||||||
"status": 'read',
|
"status": 'read'
|
||||||
"reply": 'ok'
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
|
@ -296,7 +295,7 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
"data": {
|
"data": {
|
||||||
"status": 'acknowledged',
|
"status": 'acknowledged',
|
||||||
"reply": 'ok'
|
"reply": 'OK'
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
|
|
|
@ -95,8 +95,7 @@ const NotificationDropdown = ({ t }) => {
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
"data": {
|
"data": {
|
||||||
"status": 'read',
|
"status": 'read'
|
||||||
"reply": 'ok'
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
|
|
|
@ -315,8 +315,10 @@ const resources = {
|
||||||
'Notification Message': 'Message',
|
'Notification Message': 'Message',
|
||||||
'Notification Status': 'Status',
|
'Notification Status': 'Status',
|
||||||
'Notification Mark As Read': 'Mark As Read',
|
'Notification Mark As Read': 'Mark As Read',
|
||||||
|
'Notification Mark As Acknowledged': 'Acknowledge',
|
||||||
'Notification Unread': 'Unread',
|
'Notification Unread': 'Unread',
|
||||||
'Notification Read': 'Read',
|
'Notification Read': 'Read',
|
||||||
|
'Notification Acknowledged': 'Acknowledged',
|
||||||
'Notification Archive': 'Archive',
|
'Notification Archive': 'Archive',
|
||||||
'Notification Delete': 'Delete',
|
'Notification Delete': 'Delete',
|
||||||
'Notification Apply': 'Apply',
|
'Notification Apply': 'Apply',
|
||||||
|
@ -1101,8 +1103,10 @@ const resources = {
|
||||||
'Notification Message': 'Nachricht',
|
'Notification Message': 'Nachricht',
|
||||||
'Notification Status': 'Status',
|
'Notification Status': 'Status',
|
||||||
'Notification Mark As Read': 'Mark as read',
|
'Notification Mark As Read': 'Mark as read',
|
||||||
|
'Notification Mark As Acknowledged': 'Bestätigen',
|
||||||
'Notification Unread': 'Ungelesene',
|
'Notification Unread': 'Ungelesene',
|
||||||
'Notification Read': 'Lesen',
|
'Notification Read': 'Lesen',
|
||||||
|
'Notification Acknowledged': 'Anerkannt',
|
||||||
'Notification Archive': 'Archiv',
|
'Notification Archive': 'Archiv',
|
||||||
'Notification Delete': 'Löschen',
|
'Notification Delete': 'Löschen',
|
||||||
'Notification Apply': 'Anwenden',
|
'Notification Apply': 'Anwenden',
|
||||||
|
|
Loading…
Reference in New Issue