Skip to content

Commit 06ec403

Browse files
committed
Fix comments
1 parent a651a47 commit 06ec403

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

lib/notifications.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { buildCsrfHeaders } = require("@sap-cloud-sdk/core");
2-
const { getNotificationDestination, executeRequest, createNotification } = require("./utils");
2+
const { getNotificationDestination, executeRequest, buildNotification } = require("./utils");
33

44
const NOTIFICATIONS_DESTINATION_NAME = cds.env.requires.notifications?.destination ?? "SAP_Notifications";
55
const NOTIFICATIONS_API_ENDPOINT = "v2/Notification.svc";
@@ -10,7 +10,7 @@ async function postNotification() {
1010
url: NOTIFICATIONS_API_ENDPOINT,
1111
});
1212

13-
const notification = createNotification(arguments);
13+
const notification = buildNotification(arguments);
1414

1515
if (notification) {
1616
return (await executeRequest("post", `${NOTIFICATIONS_API_ENDPOINT}/Notifications`, notification, notifServiceDest, csrfHeaders)).data.d;

lib/utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async function executeRequest(httpMethod, targetUrl, payload, notifServiceDest,
7272
return response;
7373
}
7474

75-
function createDefaultNotification(
75+
function buildDefaultNotification(
7676
recipients,
7777
priority,
7878
title,
@@ -104,7 +104,7 @@ function createDefaultNotification(
104104
};
105105
}
106106

107-
function createNotification(passedArguments) {
107+
function buildNotification(passedArguments) {
108108
let notification;
109109
if (passedArguments.length == 1 && typeof passedArguments[0] === "object" && !Array.isArray(passedArguments[0])) {
110110
notification = passedArguments[0];
@@ -119,7 +119,7 @@ function createNotification(passedArguments) {
119119
return;
120120
}
121121

122-
notification = createDefaultNotification(
122+
notification = buildDefaultNotification(
123123
recipients,
124124
priority,
125125
title,
@@ -139,5 +139,5 @@ module.exports = {
139139
getPrefix,
140140
getNotificationTypesKeyWithPrefix,
141141
executeRequest,
142-
createNotification
142+
buildNotification
143143
};

srv/notifyToConsole.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const NotificationService = require('./service');
2-
const { createNotification, readFile, doesKeyExist } = require("./../lib/utils");
2+
const { buildNotification, readFile, doesKeyExist } = require("./../lib/utils");
33
const { createNotificationTypesMap } = require("./../lib/notificationTypes");
44

55
module.exports = class NotifyToConsole extends NotificationService {
@@ -10,13 +10,12 @@ module.exports = class NotifyToConsole extends NotificationService {
1010

1111
notify() {
1212

13-
const notification = createNotification(arguments);
13+
const notification = buildNotification(arguments);
1414

1515
if (notification) {
1616
console.log(`SAP Alert Notification service notification: ${JSON.stringify(notification, null, 2)}`);
1717

18-
const typesFile = readFile(cds.env.requires.notifications.types);
19-
const existingTypes = createNotificationTypesMap(typesFile);
18+
const existingTypes = cds.notifications.local.types;
2019

2120
if (!doesKeyExist(existingTypes, notification["NotificationTypeKey"])) {
2221
console.log(`Notification Type ${notification["NotificationTypeKey"]} is not in the notification types file`);

0 commit comments

Comments
 (0)