Skip to content

Commit c3038fb

Browse files
authored
add default type and fix notification types creation (#8)
* add default template and bug fixes * uncomment isGroupable check * bug fixes * fix null check
1 parent b7ce7c1 commit c3038fb

File tree

7 files changed

+184
-150
lines changed

7 files changed

+184
-150
lines changed

cds-plugin.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,16 @@ const { createNotificationTypesMap, processNotificationTypes} = require("./lib/n
55
cds.once("served", async () => {
66
const profiles = cds.env.profiles ?? [];
77
const production = profiles.includes('production');
8-
const destination = cds.env.requires.notifications?.destination ?? "SAP_Notifications";
98

10-
if (cds.env.requires?.notifications?.types) {
11-
// read notification types
12-
const notificationTypes = readFile(cds.env.requires.notifications.types);
9+
// read notification types
10+
const notificationTypes = readFile(cds.env.requires.notifications.types);
1311

14-
// validate notification types
15-
validateNotificationTypes(notificationTypes);
16-
17-
const notificationTypesMap = createNotificationTypesMap(notificationTypes);
18-
19-
// create notification types
12+
if(validateNotificationTypes(notificationTypes)) {
2013
if (production) {
21-
await processNotificationTypes(notificationTypesMap, destination);
14+
await processNotificationTypes(notificationTypes);
2215
} else {
16+
const notificationTypesMap = createNotificationTypesMap(notificationTypes, true);
2317
cds.notifications = { local: { types: notificationTypesMap }};
2418
}
25-
} else if (!production) {
26-
cds.notifications = { local: { types: {} }};
2719
}
2820
});

0 commit comments

Comments
 (0)