@neoimpulse/cap-js-notifications 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neoimpulse/cap-js-notifications",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "A CDS plugin to provide an easy action for the notification service",
5
5
  "main": "cds-plugin.js",
6
6
  "scripts": {
@@ -11,14 +11,14 @@ module.exports = class NotifyToConsole extends cds.Service {
11
11
 
12
12
  this.on(eventsToListen, req => {
13
13
  LOG._debug && LOG.debug('Handling notification event:', req.event)
14
- const data = req.data;
15
- const type = data.type
16
- const message = data.message
14
+ const type = req.event
15
+ let message = req.data
17
16
  message.type = type
17
+ message = buildNotification(message);
18
18
  console.log (
19
19
  '\n---------------------------------------------------------------\n' +
20
20
  'Notification:', req.event,
21
- buildNotification(message),
21
+ message,
22
22
  '\n---------------------------------------------------------------\n',
23
23
  )
24
24
 
@@ -16,10 +16,11 @@ module.exports = exports = class NotifyToRest extends cds.Service {
16
16
  }
17
17
 
18
18
  async postNotification(req) {
19
- const data = req.data;
20
- const type = data.type
21
- const message = data.message
19
+ const type = req.event
20
+ let message = req.data
22
21
  message.type = type
22
+ message = buildNotification(message);
23
+
23
24
  const notificationDestination = await getNotificationDestination();
24
25
  const csrfHeaders = await buildHeadersForDestination(notificationDestination, {
25
26
  url: NOTIFICATIONS_API_ENDPOINT,
@@ -27,7 +28,7 @@ module.exports = exports = class NotifyToRest extends cds.Service {
27
28
 
28
29
  try {
29
30
  LOG._info && LOG.info(
30
- `Sending notification of key: ${notificationData.NotificationTypeKey} and version: ${notificationData.NotificationTypeVersion}`
31
+ `Sending notification of key: ${message.NotificationTypeKey} and version: ${message.NotificationTypeVersion}`
31
32
  );
32
33
  await executeHttpRequest(notificationDestination, {
33
34
  url: `${NOTIFICATIONS_API_ENDPOINT}/Notifications`,