public Mono<Void> checkAndTransferGroupOwnership(
            @Nullable Long auxiliaryCurrentOwnerId,
            @NotNull Long groupId,
            @NotNull Long successorId,
            boolean quitAfterTransfer,
            @Nullable ClientSession session) {
        try {
            Validator.notNull(groupId, "groupId");
            Validator.notNull(successorId, "successorId");
        } catch (ResponseException e) {
            return Mono.error(e);
        }
        Mono<Long> queryOwnerIdMono;
        if (auxiliaryCurrentOwnerId == null) {
            queryOwnerIdMono = queryGroupOwnerId(groupId);
        } else {
            if (successorId.equals(auxiliaryCurrentOwnerId)) {
                return Mono.empty();
            }
            queryOwnerIdMono = Mono.just(auxiliaryCurrentOwnerId);
        }
        return queryOwnerIdMono
                .switchIfEmpty(ResponseExceptionPublisherPool.transferNonexistentGroup())
                .flatMap(ownerId -> {
                    if (successorId.equals(ownerId)) {
                        return Mono.empty();
                    }
                    return groupMemberService.isGroupMember(groupId, successorId, false)
                            .flatMap(isGroupMember -> isGroupMember
                                    ? queryGroupTypeId(groupId)
                                    : Mono.error(ResponseException.get(
                                            ResponseStatusCode.GROUP_SUCCESSOR_NOT_GROUP_MEMBER)))
                            .flatMap(groupTypeId -> isAllowedToCreateGroupAndHaveGroupType(
                                    successorId,
                                    groupTypeId).flatMap(result -> {
                                        ResponseStatusCode code = result.code();
                                        if (code != ResponseStatusCode.OK) {
                                            return Mono.error(
                                                    ResponseException.get(code, result.reason()));
                                        }
                                        if (quitAfterTransfer) {
                                            return groupMemberService.deleteGroupMember(groupId,
                                                    ownerId,
                                                    session,
                                                    false);
                                        }
                                        return groupMemberService.updateGroupMember(groupId,
                                                ownerId,
                                                null,
                                                GroupMemberRole.MEMBER,
                                                null,
                                                null,
                                                session,
                                                false);
                                    })
                                    .then(groupMemberService.updateGroupMember(groupId,
                                            successorId,
                                            null,
                                            GroupMemberRole.OWNER,
                                            null,
                                            null,
                                            session,
                                            true))
                                    .then());
                });
    }
TODO: remove and keep {@link GroupService#queryGroupTypeIfActiveAndNotDeleted(Long, boolean)}
only.
turms-service/src/main/java/im/turms/service/domain/group/service/GroupService.java