Skip to content

Commit a778f61

Browse files
David-Kunzsjvans
andauthored
feat(inbox): allow inboxing inbound messages (#27)
requires @sap/cds 8.9.1. --------- Co-authored-by: sjvans <[email protected]> Co-authored-by: D050513 <[email protected]>
1 parent e36f8a1 commit a778f61

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55
The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

7+
## Version 0.1.3 - tbd
8+
9+
### Added
10+
11+
- Prerequisite for inboxing incoming messages in `@sap/cds^9`
12+
713
## Version 0.1.2 - 2024-12-12
814

915
### Fixed

cds-plugin.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const cds = require('@sap/cds')
2+
const CDS_8 = cds.version.split('.')[0] < 9
3+
24
const express = require('express')
35
const https = require('https')
46
const crypto = require('crypto')
@@ -25,11 +27,8 @@ const normalizeIncomingMessage = message => {
2527
headers = {}
2628
}
2729

28-
return {
29-
data,
30-
headers,
31-
inbound: true
32-
}
30+
if (CDS_8) return { data, headers, inbound: true }
31+
return { data, headers }
3332
}
3433

3534
const usedWebhookEndpoints = new Set()
@@ -337,7 +336,8 @@ class EventBroker extends cds.MessagingService {
337336
const context = { user: cds.User.privileged, _: msg._ }
338337
if (msg.tenant) context.tenant = msg.tenant
339338

340-
await this.tx(context, tx => tx.emit(msg))
339+
if (CDS_8) await this.tx(context, tx => tx.emit(msg))
340+
else await this.processInboundMsg(context, msg)
341341
this.LOG._debug && this.LOG.debug('Event processed successfully.')
342342
return res.status(200).json({ message: 'OK' })
343343
} catch (e) {

0 commit comments

Comments
 (0)