private Mono<Boolean> upsertOneSidedRelationship(
            @NotNull Long ownerId,
            @NotNull Long relatedUserId,
            @Nullable String name,
            @Nullable @PastOrPresent Date blockDate,
            @Nullable Date establishmentDate,
            boolean upsert,
            @Nullable ClientSession session) {
        if (blockDate != null && ownerId.equals(relatedUserId)) {
            return Mono.error(ResponseException.get(ResponseStatusCode.CANNOT_BLOCK_ONESELF));
        }
        if (establishmentDate == null) {
            establishmentDate = new Date();
        }
        UserRelationship userRelationship =
                new UserRelationship(ownerId, relatedUserId, name, blockDate, establishmentDate);
        return (upsert
                ? userRelationshipRepository.upsert(userRelationship, session)
                        .map(updateResult -> updateResult.getUpsertedId() != null)
                : userRelationshipRepository.insert(userRelationship, session)
                        .thenReturn(true)
                        .onErrorMap(DuplicateKeyException.class,
                                e -> ResponseException
                                        .get(ResponseStatusCode.CREATE_EXISTING_RELATIONSHIP)))
                .doOnSuccess(unused -> {
                    Pair<Long, Long> cacheKey = Pair.of(ownerId, relatedUserId);
                    boolean isBlocked = blockDate != null;
                    ownerIdAndRelatedUserIdToHasRelationshipAndNotBlockedCache.put(cacheKey,
                            !isBlocked);
                    ownerIdAndRelatedUserIdToIsBlockedCache.put(cacheKey, isBlocked);
                });
    }
@return true if a new relationship is created.
turms-service/src/main/java/im/turms/service/domain/user/service/UserRelationshipService.java