Skip to content

Commit

Permalink
Merge pull request #58 from tarentomaheshvakkund/4.8.10-selfregistere…
Browse files Browse the repository at this point in the history
…dornot

 KB-1722 - Create an API to get the user login details and raise the kafka event
  • Loading branch information
SaipradeepR authored Jan 10, 2024
2 parents 10ceb9b + 55d5401 commit 55d0c6f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,5 +644,7 @@ public final class JsonKey {
public static final String FIRST_LOGIN = "first_login";
public static final String EDATA = "edata";

public static final String SELF_REGISTRATION = "self_registration";
public static final String CREATEDBY = "createdby";
private JsonKey() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,12 @@ public Response getUserLoggedInDetails(Request actorMessage) throws Exception {
Map<String, Object> userDetailsMap = new HashMap<>();
List<Map<String, Object>> list = (List<Map<String, Object>>) response.get(JsonKey.RESPONSE);
list.forEach(a -> a.forEach(userDetailsMap::putIfAbsent));
Map<String, Object> map = new HashMap<>();
list.forEach(map ->
map.forEach((key, value) ->
userDetailsMap.putIfAbsent(key.toLowerCase(), value)
)
);
Map<String, Object> map = new HashMap<>();
if (userDetailsMap.get("first_login") == null) {
map.put(JsonKey.ID, userId);
map.put(JsonKey.LAST_LOGIN, new Timestamp(Calendar.getInstance().getTime().getTime()));
Expand All @@ -757,18 +762,20 @@ public Response getUserLoggedInDetails(Request actorMessage) throws Exception {
requestMap.put(JsonKey.ID, map.get(JsonKey.ID));
requestMap.put(JsonKey.LAST_LOGIN, map.get(JsonKey.LAST_LOGIN));
requestMap.put(JsonKey.FIRST_LOGIN, map.get(JsonKey.FIRST_LOGIN));
dataMap.put("edata", requestMap);
requestMap.put(JsonKey.SELF_REGISTRATION, userDetailsMap.get(JsonKey.CREATEDBY) == null);
dataMap.put(JsonKey.EDATA, requestMap);
String topic = ProjectUtil.getConfigValue("kafka_user_first_login_event_topic");
InstructionEventGenerator.createFirstLoginDetailsEvent("", topic, dataMap);
} else {
map.put(JsonKey.ID, userId);
map.put(JsonKey.LAST_LOGIN, new Timestamp(Calendar.getInstance().getTime().getTime()));
cassandraOperation.upsertRecord(JsonKey.SUNBIRD, JsonKey.USER, map, actorMessage.getRequestContext());
map.put(JsonKey.FIRST_LOGIN,userDetailsMap.get("first_login"));
map.put(JsonKey.FIRST_LOGIN,userDetailsMap.get(JsonKey.FIRST_LOGIN));
}
response.put("first_login",map.get(JsonKey.FIRST_LOGIN));
response.put("last_login",map.get(JsonKey.LAST_LOGIN));
response.put("user_id",userId);
response.put(JsonKey.FIRST_LOGIN,map.get(JsonKey.FIRST_LOGIN));
response.put(JsonKey.LAST_LOGIN,map.get(JsonKey.LAST_LOGIN));
response.put(JsonKey.CONSENT_USER_ID,userId);
response.put(JsonKey.SELF_REGISTRATION,userDetailsMap.get(JsonKey.CREATEDBY) == null);
return response;
}
}

0 comments on commit 55d0c6f

Please sign in to comment.