Skip to content

Commit 9bdbe42

Browse files
committed
Fix conflicts
1 parent 6fa55e4 commit 9bdbe42

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

lib/notifications.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
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");
33

44
const NOTIFICATIONS_DESTINATION_NAME = cds.env.requires.notifications?.destination ?? "SAP_Notifications";
55
const NOTIFICATIONS_API_ENDPOINT = "v2/Notification.svc";
6+
const POSSIBLE_PRIORITIES = ["LOW", "NEUTRAL", "MEDIUM", "HIGH"];
67

78
async function createNotificationObject(
89
recipients,
910
notificationData
1011
) {
11-
const prefix = "@cap-ans/";
12+
const prefix = "@cap-ans";
1213
// const prefix = process.env.npm_package_name;
1314
return {
1415
Id: notificationData["Id"],
@@ -63,7 +64,7 @@ async function createDefaultNotificationObject(
6364
}
6465

6566
async function postNotification() {
66-
const notifServiceDest = await _getDestination(NOTIFICATIONS_DESTINATION_NAME);
67+
const notifServiceDest = await getNotificationDestination(NOTIFICATIONS_DESTINATION_NAME);
6768
const csrfHeaders = await buildCsrfHeaders(notifServiceDest, {
6869
url: NOTIFICATIONS_API_ENDPOINT,
6970
});
@@ -88,7 +89,7 @@ async function postNotification() {
8889
arguments[0], // recipients
8990
arguments[1], // title
9091
"",
91-
"LOW"
92+
"NEUTRAL"
9293
);
9394

9495
} else if (arguments.length === 3 && POSSIBLE_PRIORITIES.includes(arguments[2])) { // using recipients, title, priority
@@ -103,7 +104,7 @@ async function postNotification() {
103104
arguments[0], // recipients
104105
arguments[1], // title
105106
arguments[2], // description
106-
"LOW"
107+
"NEUTRAL"
107108
);
108109
} else if (arguments.length === 4 && POSSIBLE_PRIORITIES.includes(arguments[3])) { // using only recipients, title, description, priority
109110
notification = await createDefaultNotificationObject(

lib/utils.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const fs = require('fs');
22
const { basename } = require('path')
33
const cds = require("@sap/cds");
4-
const { getDestination } = require("@sap-cloud-sdk/core");
4+
const { executeHttpRequest, getDestination } = require("@sap-cloud-sdk/core");
55

66
const messages = {
77
INVALID_NOTIFICATION_TYPES: "Notification Types must contain the following keys: 'NotificationTypeKey' and 'NotificationTypeVersion'.",
@@ -40,7 +40,8 @@ function getNotificationTypesKeyWithPrefix(notificationTypeKey) {
4040
const prefix = getPrefix();
4141
return `${prefix}/${notificationTypeKey}`;
4242
}
43-
async function еxecuteRequest(httpmethod, targetUrl, payload, notifServiceDest, csrfHeaders) {
43+
44+
async function executeRequest(httpmethod, targetUrl, payload, notifServiceDest, csrfHeaders) {
4445
let response = {};
4546
try {
4647
response = await executeHttpRequest(notifServiceDest, {
@@ -64,5 +65,5 @@ module.exports = {
6465
getNotificationDestination,
6566
getPrefix,
6667
getNotificationTypesKeyWithPrefix,
67-
executeRequest: еxecuteRequest
68+
executeRequest
6869
};

srv/notifyToConsole.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const NotificationService = require('./service');
22
const cds = require("@sap/cds");
33
const notifier = require("../lib/notifications");
4-
const { doesKeyExist, getNotificationTypesKeyWithPrefix } = require('../lib/utils');
54

65
module.exports = class NotifyToConsole extends NotificationService {
76
async init() {
@@ -10,6 +9,6 @@ module.exports = class NotifyToConsole extends NotificationService {
109
}
1110

1211
notify() {
13-
console.log(`[ans] - ${arguments}:`);
12+
console.log(JSON.stringify(arguments, null, 2));
1413
}
1514
}

0 commit comments

Comments
 (0)