fix(notifications): Fixed the Partially TV notifications going to the admin #4797 (#4799)

pull/4801/head
Jamie 2 years ago committed by GitHub
parent 987ec5a18c
commit bcb3e7f003
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -63,7 +63,7 @@ namespace Ombi.Notifications.Agents
// Get admin devices // Get admin devices
var playerIds = await GetPrivilegedUsersPlayerIds(); var playerIds = await GetPrivilegedUsersPlayerIds();
await Send(playerIds, notification, settings, model, true); await Send(playerIds, notification);
} }
protected override async Task NewIssue(NotificationOptions model, MobileNotificationSettings settings) protected override async Task NewIssue(NotificationOptions model, MobileNotificationSettings settings)
@ -83,7 +83,7 @@ namespace Ombi.Notifications.Agents
// Get admin devices // Get admin devices
var playerIds = await GetAdmins(); var playerIds = await GetAdmins();
await Send(playerIds, notification, settings, model); await Send(playerIds, notification);
} }
protected override async Task IssueComment(NotificationOptions model, MobileNotificationSettings settings) protected override async Task IssueComment(NotificationOptions model, MobileNotificationSettings settings)
@ -107,13 +107,13 @@ namespace Ombi.Notifications.Agents
model.Substitutes.TryGetValue("IssueId", out var issueId); model.Substitutes.TryGetValue("IssueId", out var issueId);
// Send to user // Send to user
var playerIds = await GetUsersForIssue(model, int.Parse(issueId), NotificationType.IssueComment); var playerIds = await GetUsersForIssue(model, int.Parse(issueId), NotificationType.IssueComment);
await Send(playerIds, notification, settings, model); await Send(playerIds, notification);
} }
else else
{ {
// Send to admin // Send to admin
var playerIds = await GetAdmins(); var playerIds = await GetAdmins();
await Send(playerIds, notification, settings, model); await Send(playerIds, notification);
} }
} }
} }
@ -136,7 +136,7 @@ namespace Ombi.Notifications.Agents
// Send to user // Send to user
var playerIds = await GetUsers(model, NotificationType.IssueResolved); var playerIds = await GetUsers(model, NotificationType.IssueResolved);
await Send(playerIds, notification, settings, model); await Send(playerIds, notification);
} }
@ -158,7 +158,7 @@ namespace Ombi.Notifications.Agents
// Get admin devices // Get admin devices
var playerIds = await GetAdmins(); var playerIds = await GetAdmins();
await Send(playerIds, notification, settings, model); await Send(playerIds, notification);
} }
protected override async Task RequestDeclined(NotificationOptions model, MobileNotificationSettings settings) protected override async Task RequestDeclined(NotificationOptions model, MobileNotificationSettings settings)
@ -179,7 +179,7 @@ namespace Ombi.Notifications.Agents
// Send to user // Send to user
var playerIds = await GetUsers(model, NotificationType.RequestDeclined); var playerIds = await GetUsers(model, NotificationType.RequestDeclined);
await AddSubscribedUsers(playerIds); await AddSubscribedUsers(playerIds);
await Send(playerIds, notification, settings, model); await Send(playerIds, notification);
} }
protected override async Task RequestApproved(NotificationOptions model, MobileNotificationSettings settings) protected override async Task RequestApproved(NotificationOptions model, MobileNotificationSettings settings)
@ -201,7 +201,7 @@ namespace Ombi.Notifications.Agents
var playerIds = await GetUsers(model, NotificationType.RequestApproved); var playerIds = await GetUsers(model, NotificationType.RequestApproved);
await AddSubscribedUsers(playerIds); await AddSubscribedUsers(playerIds);
await Send(playerIds, notification, settings, model); await Send(playerIds, notification);
} }
protected override async Task AvailableRequest(NotificationOptions model, MobileNotificationSettings settings) protected override async Task AvailableRequest(NotificationOptions model, MobileNotificationSettings settings)
@ -225,7 +225,7 @@ namespace Ombi.Notifications.Agents
var playerIds = await GetUsers(model, NotificationType.RequestAvailable); var playerIds = await GetUsers(model, NotificationType.RequestAvailable);
await AddSubscribedUsers(playerIds); await AddSubscribedUsers(playerIds);
await Send(playerIds, notification, settings, model); await Send(playerIds, notification);
} }
private static Dictionary<string,string> GetNotificationData(NotificationMessageContent parsed, NotificationType type) private static Dictionary<string,string> GetNotificationData(NotificationMessageContent parsed, NotificationType type)
@ -240,7 +240,7 @@ namespace Ombi.Notifications.Agents
throw new NotImplementedException(); throw new NotImplementedException();
} }
protected async Task Send(List<string> playerIds, NotificationMessage model, MobileNotificationSettings settings, NotificationOptions requestModel, bool isAdminNotification = false) protected async Task Send(List<string> playerIds, NotificationMessage model)
{ {
if (playerIds == null || !playerIds.Any()) if (playerIds == null || !playerIds.Any())
{ {
@ -276,7 +276,7 @@ namespace Ombi.Notifications.Agents
} }
var playerIds = user.NotificationUserIds.Select(x => x.PlayerId).ToList(); var playerIds = user.NotificationUserIds.Select(x => x.PlayerId).ToList();
await Send(playerIds, notification, settings, model); await Send(playerIds, notification);
} }
private async Task<List<string>> GetAdmins() private async Task<List<string>> GetAdmins()
@ -382,13 +382,15 @@ namespace Ombi.Notifications.Agents
var notification = new NotificationMessage var notification = new NotificationMessage
{ {
Message = parsed.Message, Message = parsed.Message,
Subject = "New Request", Subject = "Request Partially Available",
Data = GetNotificationData(parsed, NotificationType.PartiallyAvailable) Data = GetNotificationData(parsed, NotificationType.PartiallyAvailable)
}; };
// Get admin devices
var playerIds = await GetAdmins(); var playerIds = await GetUsers(model, NotificationType.PartiallyAvailable);
await Send(playerIds, notification, settings, model, true);
await AddSubscribedUsers(playerIds);
await Send(playerIds, notification);
} }
} }
} }
Loading…
Cancel
Save