@@ -9,7 +9,7 @@ const messages = {
9
9
TYPES_FILE_NOT_EXISTS : "Notification Types file path is incorrect." ,
10
10
INVALID_NOTIFICATION_TYPES : "Notification Types must contain the following key: 'NotificationTypeKey'." ,
11
11
DESTINATION_NOT_FOUND : "Failed to get destination: " ,
12
- MANDATORY_PARAMETER_NOT_PASSED_FOR_DEFAULT_NOTIFICATION : "Recipients, priority and title are mandatory parameters" ,
12
+ MANDATORY_PARAMETER_NOT_PASSED_FOR_DEFAULT_NOTIFICATION : "Recipients and title are mandatory parameters" ,
13
13
MANDATORY_PARAMETER_NOT_PASSED_FOR_CUSTOM_NOTIFICATION : "Recipients, type are mandatory parameters" ,
14
14
RECIPIENTS_IS_NOT_ARRAY : "Recipients is not an array or it is empty" ,
15
15
TITLE_IS_NOT_STRING : "Title is not a string" ,
@@ -32,7 +32,7 @@ function validateNotificationTypes(notificationTypes) {
32
32
}
33
33
34
34
function validateDefaultNotifyParameters ( recipients , priority , title , description ) {
35
- if ( ! recipients || ! priority || ! title ) {
35
+ if ( ! recipients || ! title ) {
36
36
console . log ( messages . MANDATORY_PARAMETER_NOT_PASSED_FOR_DEFAULT_NOTIFICATION ) ;
37
37
return false ;
38
38
}
@@ -47,12 +47,12 @@ function validateDefaultNotifyParameters(recipients, priority, title, descriptio
47
47
return false ;
48
48
}
49
49
50
- if ( ! PRIORITIES . includes ( priority ) ) {
50
+ if ( priority && ! PRIORITIES . includes ( priority . toUpperCase ( ) ) ) {
51
51
console . log ( `Invalid priority ${ priority } . Allowed priorities are LOW, NEUTRAL, MEDIUM, HIGH` ) ;
52
52
return false ;
53
53
}
54
54
55
- if ( description !== undefined && typeof description !== "string" ) {
55
+ if ( description && typeof description !== "string" ) {
56
56
console . log ( messages . DESCRIPTION_IS_NOT_STRING ) ;
57
57
return false ;
58
58
}
@@ -71,22 +71,22 @@ function validateCustomNotifyParameters(type, recipients, properties, navigation
71
71
return false ;
72
72
}
73
73
74
- if ( priority === undefined || ! PRIORITIES . includes ( priority ) ) {
74
+ if ( priority && ! PRIORITIES . includes ( priority . toUpperCase ( ) ) ) {
75
75
console . log ( `Invalid priority ${ priority } . Allowed priorities are LOW, NEUTRAL, MEDIUM, HIGH` ) ;
76
76
return false ;
77
77
}
78
78
79
- if ( properties !== undefined && ! Array . isArray ( properties ) ) {
79
+ if ( properties && ! Array . isArray ( properties ) ) {
80
80
console . log ( messages . PROPERTIES_IS_NOT_OBJECT ) ;
81
81
return false ;
82
82
}
83
83
84
- if ( navigation !== undefined && typeof navigation !== "object" ) {
84
+ if ( navigation && typeof navigation !== "object" ) {
85
85
console . log ( messages . NAVIGATION_IS_NOT_OBJECT ) ;
86
86
return false ;
87
87
}
88
88
89
- if ( payload !== undefined && typeof payload !== "object" ) {
89
+ if ( payload && typeof payload !== "object" ) {
90
90
console . log ( messages . PAYLOAD_IS_NOT_OBJECT ) ;
91
91
return false ;
92
92
}
@@ -144,7 +144,7 @@ async function executeRequest(httpMethod, targetUrl, payload, notificationDestin
144
144
145
145
function buildDefaultNotification (
146
146
recipients ,
147
- priority ,
147
+ priority = "NEUTRAL" ,
148
148
title ,
149
149
description = ""
150
150
) {
@@ -183,7 +183,7 @@ function buildCustomNotification(notificationData) {
183
183
NotificationTypeVersion : notificationData [ "payload" ] ? notificationData [ "payload" ] [ "NotificationTypeVersion" ] : "1" ,
184
184
NavigationTargetAction : notificationData [ "navigation" ] ? notificationData [ "navigation" ] [ "NavigationTargetAction" ] : undefined ,
185
185
NavigationTargetObject : notificationData [ "navigation" ] ? notificationData [ "navigation" ] [ "NavigationTargetObject" ] : undefined ,
186
- Priority : notificationData [ "priority" ] ? notificationData [ "priority" ] : "MEDIUM " ,
186
+ Priority : notificationData [ "priority" ] ? notificationData [ "priority" ] : "NEUTRAL " ,
187
187
ProviderId : notificationData [ "payload" ] ? notificationData [ "payload" ] [ "ProviderId" ] : undefined ,
188
188
ActorId : notificationData [ "payload" ] ? notificationData [ "payload" ] [ "ActorId" ] : undefined ,
189
189
ActorDisplayText : notificationData [ "payload" ] ? notificationData [ "payload" ] [ "ActorDisplayText" ] : undefined ,
@@ -239,4 +239,3 @@ module.exports = {
239
239
executeRequest,
240
240
buildNotification
241
241
} ;
242
-
0 commit comments