private Mono<UserSessionsStatus> handleUserSessionsStatusEntries(
            Long userId,
            List<Map.Entry<Object, Object>> entries) {
        UserStatus userStatus = null;
        Map<DeviceType, UserDeviceSessionInfo> onlineDeviceTypeToSessionInfo = null;
        List<Pair<String, Long>> nodeIdToHeartbeatTimestampPairs = new ArrayList<>(entries.size());
        UserStatusField field;
        Object value;
        long now = System.currentTimeMillis();

        for (Map.Entry<Object, Object> entry : entries) {
            field = (UserStatusField) entry.getKey();
            value = entry.getValue();
            UserStatusFieldType fieldedType = field.fieldType();
            if (fieldedType == UserStatusFieldType.USER_STATUS) {
                userStatus = (UserStatus) value;
                continue;
            }
            switch (fieldedType) {
                case DEVICE_TYPE_TO_NODE_ID -> {
                    if (onlineDeviceTypeToSessionInfo == null) {
                        onlineDeviceTypeToSessionInfo = new FastEnumMap<>(DeviceType.class);
                    }
                    UserDeviceSessionInfo sessionInfo = onlineDeviceTypeToSessionInfo
                            .computeIfAbsent((DeviceType) field.value(),
                                    // Set "isActive" to true for backward
                                    // compatibility
                                    type -> new UserDeviceSessionInfo(true));
                    sessionInfo.setNodeId((String) value);
                }
                case NODE_ID_TO_HEARTBEAT_TIMESTAMP -> nodeIdToHeartbeatTimestampPairs
                        .add(Pair.of((String) field.value(), (Long) value));
            }
        }
        if (onlineDeviceTypeToSessionInfo == null) {
            userStatus = UserStatus.OFFLINE;
            onlineDeviceTypeToSessionInfo = Collections.emptyMap();
        } else {
            if (onlineDeviceTypeToSessionInfo.isEmpty()) {
                userStatus = UserStatus.OFFLINE;
            } else {
                Collection<UserDeviceSessionInfo> sessionInfos =
                        onlineDeviceTypeToSessionInfo.values();
                int infoCount = sessionInfos.size();
                if (infoCount == 1
                        && localNodeId.equals(sessionInfos.iterator()
                                .next()
                                .getNodeId())) {
                    if (userStatus == null || userStatus == UserStatus.OFFLINE) {
                        userStatus = UserStatus.AVAILABLE;
                    }
                } else {
                    int activeNodeCount = nodeIdToHeartbeatTimestampPairs.size();
                    for (Pair<String, Long> pair : nodeIdToHeartbeatTimestampPairs) {
                        String nodeId = pair.first();
                        Long timestampSeconds = pair.second();
                        boolean isActive = now - timestampSeconds * 1000L <= deviceStatusTtlMillis;
                        if (!isActive) {
                            activeNodeCount--;
                        }
                        for (UserDeviceSessionInfo sessionInfo : sessionInfos) {
                            if (nodeId.equals(sessionInfo.getNodeId())) {
                                sessionInfo.setHeartbeatTimestampSeconds(timestampSeconds);
                                sessionInfo.setActive(isActive);
                            }
                        }
                    }
                    if (activeNodeCount == 0) {
                        userStatus = UserStatus.OFFLINE;
                        UserSessionsStatus userSessionsStatus = new UserSessionsStatus(
                                userId,
                                userStatus,
                                onlineDeviceTypeToSessionInfo);
                        return Mono.just(userSessionsStatus);
                    }
                    return detectInactiveNodesAndUpdateActiveInfos(userId,
                            sessionInfos,
                            infoCount,
                            onlineDeviceTypeToSessionInfo,
                            userStatus);
                }
            }
        }
        UserSessionsStatus userSessionsStatus =
                new UserSessionsStatus(userId, userStatus, onlineDeviceTypeToSessionInfo);
        return Mono.just(userSessionsStatus);
    }
@return {@link UserStatus#OFFLINE} instead of MonoEmpty for the offline user
turms-server-common/src/main/java/im/turms/server/common/domain/session/service/UserStatusService.java