Exemplo n.º 1
0
    public async Task <Either <BaseError, Unit> > Handle(
        SynchronizeJellyfinCollections request,
        CancellationToken cancellationToken)
    {
        Validation <BaseError, ConnectionParameters> validation = await Validate(request);

        return(await validation.Match(
                   SynchronizeCollections,
                   error => Task.FromResult <Either <BaseError, Unit> >(error.Join())));
    }
Exemplo n.º 2
0
    private async Task SynchronizeJellyfinCollections(
        SynchronizeJellyfinCollections request,
        CancellationToken cancellationToken)
    {
        using IServiceScope scope = _serviceScopeFactory.CreateScope();
        IMediator mediator = scope.ServiceProvider.GetRequiredService <IMediator>();

        Either <BaseError, Unit> result = await mediator.Send(request, cancellationToken);

        result.BiIter(
            _ => _logger.LogDebug("Done synchronizing jellyfin collections"),
            error => _logger.LogWarning(
                "Unable to synchronize jellyfin collections for source {MediaSourceId}: {Error}",
                request.JellyfinMediaSourceId,
                error.Value));
    }
Exemplo n.º 3
0
 private Task <Validation <BaseError, JellyfinMediaSource> > MediaSourceMustExist(
     SynchronizeJellyfinCollections request) =>
 _mediaSourceRepository.GetJellyfin(request.JellyfinMediaSourceId)
 .Map(o => o.ToValidation <BaseError>("Jellyfin media source does not exist."));
Exemplo n.º 4
0
 private Task <Validation <BaseError, ConnectionParameters> > Validate(SynchronizeJellyfinCollections request) =>
 MediaSourceMustExist(request)
 .BindT(MediaSourceMustHaveActiveConnection)
 .BindT(MediaSourceMustHaveApiKey);