diff --git a/core/platform-common/src/main/java/org/sunbird/keys/JsonKey.java b/core/platform-common/src/main/java/org/sunbird/keys/JsonKey.java index 6166d89ceb..c5bb868feb 100644 --- a/core/platform-common/src/main/java/org/sunbird/keys/JsonKey.java +++ b/core/platform-common/src/main/java/org/sunbird/keys/JsonKey.java @@ -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() {} } diff --git a/service/src/main/java/org/sunbird/service/user/UserProfileReadService.java b/service/src/main/java/org/sunbird/service/user/UserProfileReadService.java index e4ed326d5d..fd7b817ae2 100644 --- a/service/src/main/java/org/sunbird/service/user/UserProfileReadService.java +++ b/service/src/main/java/org/sunbird/service/user/UserProfileReadService.java @@ -746,7 +746,12 @@ public Response getUserLoggedInDetails(Request actorMessage) throws Exception { Map userDetailsMap = new HashMap<>(); List> list = (List>) response.get(JsonKey.RESPONSE); list.forEach(a -> a.forEach(userDetailsMap::putIfAbsent)); - Map map = new HashMap<>(); + list.forEach(map -> + map.forEach((key, value) -> + userDetailsMap.putIfAbsent(key.toLowerCase(), value) + ) + ); + Map 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())); @@ -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; } }