mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-05-08 12:43:19 +02:00
Fix NullRef in analytics service
This commit is contained in:
parent
cdb1f163f8
commit
d1949d24e0
1 changed files with 5 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Cloud;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
|
@ -14,6 +16,7 @@ public class ReleaseAnalyticsService : IHandleAsync<IndexerQueryEvent>
|
|||
private readonly IHttpClient _httpClient;
|
||||
private readonly IHttpRequestBuilderFactory _requestBuilder;
|
||||
private readonly IAnalyticsService _analyticsService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public ReleaseAnalyticsService(IHttpClient httpClient, IProwlarrCloudRequestBuilder requestBuilder, IAnalyticsService analyticsService)
|
||||
{
|
||||
|
|
@ -24,7 +27,7 @@ public ReleaseAnalyticsService(IHttpClient httpClient, IProwlarrCloudRequestBuil
|
|||
|
||||
public void HandleAsync(IndexerQueryEvent message)
|
||||
{
|
||||
if (_analyticsService.IsEnabled)
|
||||
if (_analyticsService.IsEnabled && message.QueryResult?.Releases != null)
|
||||
{
|
||||
var request = _requestBuilder.Create().Resource("release/push").Build();
|
||||
request.Method = HttpMethod.Post;
|
||||
|
|
@ -34,7 +37,7 @@ public void HandleAsync(IndexerQueryEvent message)
|
|||
var body = message.QueryResult.Releases.Select(x => new
|
||||
{
|
||||
Title = x.Title,
|
||||
Categories = x.Categories.Where(c => c.Id < 10000).Select(c => c.Id),
|
||||
Categories = x.Categories?.Where(c => c.Id < 10000).Select(c => c.Id) ?? new List<int>(),
|
||||
Protocol = x.DownloadProtocol.ToString(),
|
||||
Size = x.Size,
|
||||
PublishDate = x.PublishDate
|
||||
|
|
|
|||
Loading…
Reference in a new issue