updated Web Message actions in API and Notification Page in Web UI

pull/123/head
13621160019@163.com 2022-02-12 15:53:55 +08:00
parent 12843792f1
commit 1e652da94d
5 changed files with 46 additions and 16 deletions

View File

@ -2144,21 +2144,45 @@ Result in JSON
| message | string | Web Message Body |
| created_datetime| float | Web Message Created Datetime (POSIX timestamp * 1000)|
| 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
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
```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
```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'
```
* DELETE a Web Message by ID
* PUT Update a Web Message (Acknowledge)
```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 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
```bash
curl --location --request DELETE '{{base_url}}/webmessages/{id}' \
--header 'User-UUID: dcdb67d1-6116-4987-916f-6fc6cf2bc0e4' \
--header 'Token: 24bb236244f26784fb1397344d926b4871e87a90096eae926a0e448396dbd3ff4a2f70f727089f025238cb47bdbccdc877ef4a50fad8f05a4e5100c5d3eb0d3c'
```
### Wechat Message

View File

@ -367,17 +367,21 @@ class WebMessageItem:
if 'status' not in new_values['data'].keys() or \
not isinstance(new_values['data']['status'], str) 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',
description='API.INVALID_STATUS')
status = str.strip(new_values['data']['status'])
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:
# 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'])
reply = str.strip(new_values['data']['reply'])
else:
reply = None
# Verify User Session
token = req.headers.get('TOKEN')

View File

@ -260,8 +260,7 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
},
body: JSON.stringify({
"data": {
"status": 'read',
"reply": 'ok'
"status": 'read'
}
}),
}).then(response => {
@ -296,7 +295,7 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
body: JSON.stringify({
"data": {
"status": 'acknowledged',
"reply": 'ok'
"reply": 'OK'
}
}),
}).then(response => {

View File

@ -95,8 +95,7 @@ const NotificationDropdown = ({ t }) => {
},
body: JSON.stringify({
"data": {
"status": 'read',
"reply": 'ok'
"status": 'read'
}
}),
}).then(response => {

View File

@ -315,8 +315,10 @@ const resources = {
'Notification Message': 'Message',
'Notification Status': 'Status',
'Notification Mark As Read': 'Mark As Read',
'Notification Mark As Acknowledged': 'Acknowledge',
'Notification Unread': 'Unread',
'Notification Read': 'Read',
'Notification Acknowledged': 'Acknowledged',
'Notification Archive': 'Archive',
'Notification Delete': 'Delete',
'Notification Apply': 'Apply',
@ -1101,8 +1103,10 @@ const resources = {
'Notification Message': 'Nachricht',
'Notification Status': 'Status',
'Notification Mark As Read': 'Mark as read',
'Notification Mark As Acknowledged': 'Bestätigen',
'Notification Unread': 'Ungelesene',
'Notification Read': 'Lesen',
'Notification Acknowledged': 'Anerkannt',
'Notification Archive': 'Archiv',
'Notification Delete': 'Löschen',
'Notification Apply': 'Anwenden',