Skip to content

Commit

Permalink
addition of fcm token
Browse files Browse the repository at this point in the history
  • Loading branch information
surabhi-mahawar committed Jun 2, 2022
1 parent 8d20fb6 commit b927a2f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/main/java/com/uci/orchestrator/Consumer/ReactiveConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,14 @@ private String getFederatedUsersMeta(JsonNode campaign, JsonNode transformer) {
/* Get federated users from federation services */
JSONArray users = userService.getUsersFromFederatedServers(campaignID);

if(users != null) {
/* Create request body data for user template message */
if(users != null && transformer.get("meta") != null) {
/* Create request body data for user template message */
ObjectMapper mapper = new ObjectMapper();
ObjectNode node = mapper.createObjectNode();
node.put("body", transformer.get("meta").get("body").asText());
node.put("type", transformer.get("meta").get("type").asText());
node.put("user", transformer.get("meta").get("user").asText());
node.put("user", transformer.get("meta").get("user") != null ?
transformer.get("meta").get("user").asText() : "");

ArrayNode sampleData = mapper.createArrayNode();
for (int i = 0; i < users.length(); i++) {
Expand Down Expand Up @@ -308,14 +309,21 @@ private String getFederatedUsersMeta(JsonNode campaign, JsonNode transformer) {
ArrayNode userMetaData = mapper.createArrayNode();
usersMessage.forEach(userMsg -> {
int j = Integer.parseInt(userMsg.get("__index").toString());
String userPhone = ((JSONObject) users.get(j)).getString("phoneNo");
// userPhone = "7597185708";
JSONObject userObj = ((JSONObject) users.get(j));
String userPhone = userObj.getString("phoneNo");

ObjectNode map = mapper.createObjectNode();
map.put("phone", userPhone);
map.put("message", userMsg.get("body").toString());
try{
if(userObj.get("fcmToken") != null) {
map.put("fcmToken", userObj.getString("fcmToken"));
}
} catch (Exception e) {
//
}

userMetaData.add(map);

log.info("index: "+j+", body: "+userMsg.get("body").toString()+", phone:"+userPhone);
});

Expand Down

0 comments on commit b927a2f

Please sign in to comment.