private Mono<UserSessionsStatus> detectInactiveNodesAndUpdateActiveInfos(
            Long userId,
            Collection<UserDeviceSessionInfo> sessionInfos,
            int nodeCount,
            Map<DeviceType, UserDeviceSessionInfo> onlineDeviceTypeToSessionInfo,
            @Nullable UserStatus userStatus) {
        List<Mono<Pair<String, NodeStatus>>> fetchNodeStatuses = new ArrayList<>(nodeCount);
        for (UserDeviceSessionInfo sessionInfo : sessionInfos) {
            if (sessionInfo.isActive()) {
                String nodeId = sessionInfo.getNodeId();
                if (!localNodeId.equals(nodeId)) {
                    fetchNodeStatuses
                            .add(fetchNodeStatus(nodeId).map(status -> Pair.of(nodeId, status)));
                }
            }
        }
        return Flux.merge(fetchNodeStatuses)
                .collect(CollectorUtil.toList(fetchNodeStatuses.size()))
                .map(pairs -> {
                    int activeNodeCount = pairs.size();
                    for (Pair<String, NodeStatus> pair : pairs) {
                        NodeStatus status = pair.second();
                        if (!status.isActive) {
                            activeNodeCount--;
                            String nodeId = pair.first();
                            for (Map.Entry<DeviceType, UserDeviceSessionInfo> entry : onlineDeviceTypeToSessionInfo
                                    .entrySet()) {
                                UserDeviceSessionInfo sessionInfo = entry.getValue();
                                if (sessionInfo.getNodeId()
                                        .equals(nodeId)) {
                                    sessionInfo.setActive(false);
                                }
                            }
                        }
                    }
                    UserStatus status;
                    if (activeNodeCount == 0) {
                        status = UserStatus.OFFLINE;
                    } else if (userStatus == null || userStatus == UserStatus.OFFLINE) {
                        status = UserStatus.AVAILABLE;
                    } else {
                        status = userStatus;
                    }
                    return new UserSessionsStatus(userId, status, onlineDeviceTypeToSessionInfo);
                });
    }
@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