Skip to content

Commit

Permalink
fix : update notification-invoke-service to accept list of notificati…
Browse files Browse the repository at this point in the history
…ons or single notification in the payload
  • Loading branch information
raviteja-mandala authored and santhosh-challa committed Apr 20, 2023
1 parent 1f14989 commit 1e9792b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion installer/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
'notification.appsync' : {'tags' : ["notification"]}
}

LAMBDA_PATH = "V3"

LAMBDA_PATH = "V4"
DATA_DIR = os.path.join(BASE_APP_DIR, 'data')
LOG_DIR = os.path.join(BASE_APP_DIR, 'log')
PROVISIONER_FILES_DIR_TO_COPY = os.path.join(BASE_APP_DIR, 'files')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ public String handleRequest(Map<String,Object> event, Context context)
System.out.println("bodyJson--"+bodyJson.toString());
payloadString = bodyJson.getAsJsonObject().get("Sns").getAsJsonObject().get("Message").getAsString();
}

Object payloadObj = gson.fromJson(payloadString,Object.class);
if(payloadObj instanceof List){
List<Object> notificationRequestList = gson.fromJson(payloadString,List.class);
notificationRequestList.stream().forEach(obj -> {
String notificationRequestStr = gson.toJson(obj);
System.out.println("notificationsrequeststr for list---"+notificationRequestStr);
PublishRequest request = new PublishRequest(snsTopicArn,notificationRequestStr);
PublishResult result = client.publish(request);
logger.log("message sent with id "+result.getMessageId());
});
}
else{
System.out.println("notificationsrequeststr for single event---"+payloadObj.toString());
PublishRequest request = new PublishRequest(snsTopicArn,payloadObj.toString());
PublishResult result = client.publish(request);
logger.log("message sent with id "+result.getMessageId());
}


List<Object> notificationRequestList = gson.fromJson(payloadString,List.class);
notificationRequestList.stream().forEach(obj -> {
String notificationRequestStr = gson.toJson(obj);
Expand Down

0 comments on commit 1e9792b

Please sign in to comment.