Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const messages = {
EMPTY_OBJECT_FOR_NOTIFY: "Empty object is passed a single parameter to notify function.",
NO_OBJECT_FOR_NOTIFY: "An object must be passed to notify function."
};
//See: https://help.sap.com/docs/build-work-zone-standard-edition/sap-build-work-zone-standard-edition/developing-cloud-foundry-applications-with-notifications
const supportedANSLanguages = {AF: 1, AR: 1, BG: 1, CA: 1, ZH: 1, ZF: 1, HR: 1, CS: 1, DA: 1, NL: 1, EN: 1, ET: 1, FI: 1, FR: 1, KM: 1, DE: 1, EL: 1, HE: 1, HU: 1, IS: 1, ID: 1, IT: 1, HI: 1, JA: 1, KO: 1, LV: 1, LT: 1, MS: 1, NO: 1, NB: 1, PL: 1, PT: 1, Z1: 1, RO: 1, RU: 1, SR: 1, SH: 1, SK: 1, VI: 1, SL: 1, ES: 1, SV: 1, TH: 1, TR: 1, UK: 1, IW: 1, IN: 1, ZH_HANS: 1, ZH_HANT: 1, ZH_CN: 1, ZH_TW: 1}

const sanitizedLocale = () => cds.context?.locale && supportedANSLanguages[cds.context.locale] != undefined ? cds.context.locale : 'en'

function validateNotificationTypes(notificationTypes) {
for(let notificationType of notificationTypes){
Expand Down Expand Up @@ -141,14 +145,14 @@ function buildDefaultNotification(
const properties = [
{
Key: "title",
Language: "en",
Language: sanitizedLocale(),
Value: title,
Type: "String",
IsSensitive: false,
},
{
Key: "description",
Language: "en",
Language: sanitizedLocale(),
Value: description,
Type: "String",
IsSensitive: false,
Expand All @@ -172,7 +176,7 @@ function buildCustomNotification(_) {
Recipients: _.Recipients || _.recipients?.map(id => ({ RecipientId: id })),
Priority: _.Priority || _.priority || "NEUTRAL",
Properties: _.Properties || Object.entries(_.data).map(([k,v]) => ({
Key:k, Value:v, Language: "en", Type: typeof v, // IsSensitive: false
Key:k, Value:v, Language: sanitizedLocale(), Type: typeof v, IsSensitive: true //Is sensitive so all data is encrypted and stored in DB in ANS
})),

// Low-level API properties
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading