Exemplo n.º 1
0
        public async Task <RuleResult> Execute(SearchViewModel obj)
        {
            if (obj.Type == RequestType.Movie)
            {
                // Check if it's in Radarr
                var result = await _ctx.FirstOrDefaultAsync(x => x.TheMovieDbId == obj.Id);

                if (result != null)
                {
                    obj.Approved =
                        true; // It's in cp so it's approved... Maybe have a new property called "Processing" or something?
                }
            }
            return(Success());
        }
Exemplo n.º 2
0
        public async Task Execute(IJobExecutionContext ctx)
        {
            await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
            .SendAsync(NotificationHub.NotificationEvent, "Lidarr Availability Check Started");

            var allAlbumRequests = _requestRepository.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available);
            var albumsToUpdate   = new List <AlbumRequest>();

            foreach (var request in allAlbumRequests)
            {
                // Check if we have it cached
                var cachedAlbum = await _cachedAlbums.FirstOrDefaultAsync(x => x.ForeignAlbumId.Equals(request.ForeignAlbumId));

                if (cachedAlbum != null)
                {
                    if (cachedAlbum.FullyAvailable) // ensure we have all tracks
                    {
                        request.Available         = true;
                        request.MarkedAsAvailable = DateTime.Now;
                        albumsToUpdate.Add(request);
                    }
                }
            }

            foreach (var albumRequest in albumsToUpdate)
            {
                await _requestRepository.Update(albumRequest);

                var recipient = albumRequest.RequestedUser.Email.HasValue() ? albumRequest.RequestedUser.Email : string.Empty;

                _logger.LogDebug("AlbumId: {0}, RequestUser: {1}", albumRequest.Id, recipient);


                await _notificationService.Notify(new NotificationOptions
                {
                    DateTime         = DateTime.Now,
                    NotificationType = NotificationType.RequestAvailable,
                    RequestId        = albumRequest.Id,
                    RequestType      = RequestType.Album,
                    Recipient        = recipient,
                });
            }

            await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
            .SendAsync(NotificationHub.NotificationEvent, "Lidarr Availability Check Finished");
        }