diff --git a/Dodo1000Bot.Api/Dodo1000Bot.Api.csproj b/Dodo1000Bot.Api/Dodo1000Bot.Api.csproj index a8b6024..8d5b929 100644 --- a/Dodo1000Bot.Api/Dodo1000Bot.Api.csproj +++ b/Dodo1000Bot.Api/Dodo1000Bot.Api.csproj @@ -2,7 +2,7 @@ net6.0 - 1.22.0 + 1.23.0 f449de95-800a-40ef-8716-6e80b7f0977d diff --git a/Dodo1000Bot.Api/appsettings.json b/Dodo1000Bot.Api/appsettings.json index ee22402..de8608a 100644 --- a/Dodo1000Bot.Api/appsettings.json +++ b/Dodo1000Bot.Api/appsettings.json @@ -24,7 +24,7 @@ "KeyPrefix": "" }, "PushNotifications": { - "EveryTime": "0:05:00" + "EveryTime": "0:01:00" }, "UnitsJob": { "RefreshEveryTime": "0:55:00" diff --git a/Dodo1000Bot.Services/NotificationsService.cs b/Dodo1000Bot.Services/NotificationsService.cs index 8c353b1..3c52952 100644 --- a/Dodo1000Bot.Services/NotificationsService.cs +++ b/Dodo1000Bot.Services/NotificationsService.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using Dodo1000Bot.Models; using Dodo1000Bot.Models.Domain; using Microsoft.Extensions.Logging; @@ -42,6 +43,8 @@ public async Task PushNotifications(CancellationToken cancellationToken) return; } + notifications = notifications.Where(n => n.Type != NotificationType.NewUnit).ToList(); + IEnumerable>> tasks = _notifyServices.Select(s => s.NotifyAbout(notifications, cancellationToken)); IEnumerable[] tasksResults = await Task.WhenAll(tasks); diff --git a/Dodo1000Bot.Services/Repositories/NotificationsRepository.cs b/Dodo1000Bot.Services/Repositories/NotificationsRepository.cs index 84ed2b4..b6e4b1c 100644 --- a/Dodo1000Bot.Services/Repositories/NotificationsRepository.cs +++ b/Dodo1000Bot.Services/Repositories/NotificationsRepository.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Data; using System.Linq; @@ -43,10 +44,15 @@ LEFT JOIN pushed_notifications pn ON n.Id = pn.notificationId WHERE pn.id IS NULL", cancellationToken: cancellationToken)); - var notifications = records.Select(r => new Notification(r.Type is NotificationType ? (NotificationType)r.Type : NotificationType.Custom) + + var notifications = records.Select(r => { - Id = r.Id, - Payload = JsonSerializer.Deserialize(r.Payload) + var type = Enum.Parse(r.Type.ToString()); + return new Notification(type) + { + Id = r.Id, + Payload = JsonSerializer.Deserialize(r.Payload) + }; }).ToImmutableArray(); return notifications;