1
- const { executeHttpRequest , buildCsrfHeaders } = require ( "@sap-cloud-sdk/core" ) ;
2
- const { getNotificationDestination, getNotificationTypesKeyWithPrefix } = require ( "./utils" ) ;
1
+ const { buildCsrfHeaders } = require ( "@sap-cloud-sdk/core" ) ;
2
+ const { getNotificationDestination, getNotificationTypesKeyWithPrefix, executeRequest } = require ( "./utils" ) ;
3
3
4
4
const NOTIFICATIONS_DESTINATION_NAME = cds . env . requires . notifications ?. destination ?? "SAP_Notifications" ;
5
5
const NOTIFICATIONS_API_ENDPOINT = "v2/Notification.svc" ;
6
+ const POSSIBLE_PRIORITIES = [ "LOW" , "NEUTRAL" , "MEDIUM" , "HIGH" ] ;
6
7
7
8
async function createNotificationObject (
8
9
recipients ,
9
10
notificationData
10
11
) {
11
- const prefix = "@cap-ans/ " ;
12
+ const prefix = "@cap-ans" ;
12
13
// const prefix = process.env.npm_package_name;
13
14
return {
14
15
Id : notificationData [ "Id" ] ,
@@ -63,7 +64,7 @@ async function createDefaultNotificationObject(
63
64
}
64
65
65
66
async function postNotification ( ) {
66
- const notifServiceDest = await _getDestination ( NOTIFICATIONS_DESTINATION_NAME ) ;
67
+ const notifServiceDest = await getNotificationDestination ( NOTIFICATIONS_DESTINATION_NAME ) ;
67
68
const csrfHeaders = await buildCsrfHeaders ( notifServiceDest , {
68
69
url : NOTIFICATIONS_API_ENDPOINT ,
69
70
} ) ;
@@ -88,7 +89,7 @@ async function postNotification() {
88
89
arguments [ 0 ] , // recipients
89
90
arguments [ 1 ] , // title
90
91
"" ,
91
- "LOW "
92
+ "NEUTRAL "
92
93
) ;
93
94
94
95
} else if ( arguments . length === 3 && POSSIBLE_PRIORITIES . includes ( arguments [ 2 ] ) ) { // using recipients, title, priority
@@ -103,7 +104,7 @@ async function postNotification() {
103
104
arguments [ 0 ] , // recipients
104
105
arguments [ 1 ] , // title
105
106
arguments [ 2 ] , // description
106
- "LOW "
107
+ "NEUTRAL "
107
108
) ;
108
109
} else if ( arguments . length === 4 && POSSIBLE_PRIORITIES . includes ( arguments [ 3 ] ) ) { // using only recipients, title, description, priority
109
110
notification = await createDefaultNotificationObject (
0 commit comments