public Mono<UpdateResult> updateUsers(
            @NotEmpty Set<Long> userIds,
            @Nullable String rawPassword,
            @Nullable String name,
            @Nullable String intro,
            @Nullable String profilePicture,
            @Nullable @ValidProfileAccess ProfileAccessStrategy profileAccessStrategy,
            @Nullable Long roleId,
            @Nullable @PastOrPresent Date registrationDate,
            @Nullable Boolean isActive,
            @Nullable Map<String, Object> userDefinedAttributes) {
        try {
            Validator.notEmpty(userIds, "userIds");
            Validator.length(rawPassword,
                    "rawPassword",
                    minPasswordLengthForUpdate,
                    maxPasswordLength);
            Validator.maxLength(name, "name", maxNameLength);
            Validator.maxLength(intro, "intro", maxIntroLength);
            Validator.maxLength(profilePicture, "profilePicture", maxProfilePictureLength);
            DataValidator.validProfileAccess(profileAccessStrategy);
            Validator.pastOrPresent(registrationDate, "registrationDate");
        } catch (ResponseException e) {
            return Mono.error(e);
        }
        if (Validator.areAllFalsy(rawPassword,
                name,
                intro,
                profilePicture,
                profileAccessStrategy,
                roleId,
                registrationDate,
                isActive,
                userDefinedAttributes)) {
            return OperationResultPublisherPool.ACKNOWLEDGED_UPDATE_RESULT;
        }
        // Save an empty string "" is supported if it passes validation
        byte[] password = rawPassword == null
                ? null
                : passwordManager.encodeUserPassword(rawPassword);

        if (name == null || !elasticsearchManager.isUserUseCaseEnabled()) {
            return updateUsers(userIds,
                    name,
                    intro,
                    profilePicture,
                    profileAccessStrategy,
                    roleId,
                    registrationDate,
                    isActive,
                    password,
                    userDefinedAttributes,
                    null);
        }
        if (elasticsearchManager.isTransactionWithMongoEnabledForUser()) {
            return userRepository.inTransaction(session -> updateUsers(userIds,
                    name,
                    intro,
                    profilePicture,
                    profileAccessStrategy,
                    roleId,
                    registrationDate,
                    isActive,
                    password,
                    userDefinedAttributes,
                    session).flatMap(updateResult -> {
                        if (updateResult.getModifiedCount() == 0) {
                            return Mono.just(updateResult);
                        }
                        Mono<?> syncUserDocs = name.isBlank()
                                ? elasticsearchManager.deleteUserDocs(userIds)
                                : elasticsearchManager.putUserDocs(userIds, name);
                        return syncUserDocs.thenReturn(updateResult);
                    }));
        }
        return updateUsers(userIds,
                name,
                intro,
                profilePicture,
                profileAccessStrategy,
                roleId,
                registrationDate,
                isActive,
                password,
                userDefinedAttributes,
                null).doOnSuccess(ignored -> {
                    if (name.isBlank()) {
                        elasticsearchManager.deleteUserDocs(userIds)
                                .subscribe(null,
                                        t -> LOGGER.error(
                                                "Caught an error while deleting the docs of the users {}",
                                                userIds,
                                                t));
                    } else {
                        elasticsearchManager.putUserDocs(userIds, name)
                                .subscribe(null,
                                        t -> LOGGER.error(
                                                "Caught an error while updating the docs of the users {}",
                                                userIds,
                                                t));
                    }
                });
    }
@return Possible codes: {@link ResponseStatusCode#OK}
        {@link ResponseStatusCode#NOT_FRIEND_TO_QUERY_USER_PROFILE}
        {@link ResponseStatusCode#BLOCKED_USER_TO_QUERY_USER_PROFILE}
        {@link ResponseStatusCode#SERVER_INTERNAL_ERROR}
        {@link ResponseStatusCode#RESOURCE_NOT_FOUND}
turms-service/src/main/java/im/turms/service/domain/user/service/UserService.java