public Mono<Integer> upsertRelationshipGroupMember(
            @NotNull Long ownerId,
            @NotNull Long relatedUserId,
            @Nullable Integer newGroupIndex,
            @Nullable Integer deleteGroupIndex,
            @Nullable ClientSession session) {
        try {
            Validator.notNull(ownerId, "ownerId");
            Validator.notNull(relatedUserId, "relatedUserId");
        } catch (ResponseException e) {
            return Mono.error(e);
        }
        if (newGroupIndex != null) {
            if (deleteGroupIndex != null) {
                if (!newGroupIndex.equals(deleteGroupIndex)) {
                    return moveRelatedUserToNewGroup(ownerId,
                            relatedUserId,
                            deleteGroupIndex,
                            newGroupIndex,
                            false,
                            session).thenReturn(newGroupIndex);
                }
            } else {
                return addRelatedUserToRelationshipGroups(ownerId,
                        newGroupIndex,
                        relatedUserId,
                        session).flatMap(
                                addedNewRelatedUser -> addedNewRelatedUser
                                        ? Mono.just(newGroupIndex)
                                        : Mono.empty());
            }
        } else if (deleteGroupIndex != null
                && (!deleteGroupIndex.equals(DEFAULT_RELATIONSHIP_GROUP_INDEX))) {
            // TODO: Support specifying the behavior when a user removes a relationship from all
            // relationship groups (delete the relationship or not)
            // https://github.com/turms-im/turms/issues/1382
            return moveRelatedUserToNewGroup(ownerId,
                    relatedUserId,
                    deleteGroupIndex,
                    DEFAULT_RELATIONSHIP_GROUP_INDEX,
                    true,
                    session).thenReturn(DEFAULT_RELATIONSHIP_GROUP_INDEX);
        }
        return Mono.empty();
    }
@return the relationship index only if the related user is added to the group.
turms-service/src/main/java/im/turms/service/domain/user/service/UserRelationshipGroupService.java