Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions src/Ombi.Notifications/Agents/MobileNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected override async Task NewRequest(NotificationOptions model, MobileNotifi

// Get admin devices
var playerIds = await GetPrivilegedUsersPlayerIds();
await Send(playerIds, notification, settings, model, true);
await Send(playerIds, notification);
}

protected override async Task NewIssue(NotificationOptions model, MobileNotificationSettings settings)
Expand All @@ -83,7 +83,7 @@ protected override async Task NewIssue(NotificationOptions model, MobileNotifica

// Get admin devices
var playerIds = await GetAdmins();
await Send(playerIds, notification, settings, model);
await Send(playerIds, notification);
}

protected override async Task IssueComment(NotificationOptions model, MobileNotificationSettings settings)
Expand All @@ -107,13 +107,13 @@ protected override async Task IssueComment(NotificationOptions model, MobileNoti
model.Substitutes.TryGetValue("IssueId", out var issueId);
// Send to user
var playerIds = await GetUsersForIssue(model, int.Parse(issueId), NotificationType.IssueComment);
await Send(playerIds, notification, settings, model);
await Send(playerIds, notification);
}
else
{
// Send to admin
var playerIds = await GetAdmins();
await Send(playerIds, notification, settings, model);
await Send(playerIds, notification);
}
}
}
Expand All @@ -136,7 +136,7 @@ protected override async Task IssueResolved(NotificationOptions model, MobileNot
// Send to user
var playerIds = await GetUsers(model, NotificationType.IssueResolved);

await Send(playerIds, notification, settings, model);
await Send(playerIds, notification);
}


Expand All @@ -158,7 +158,7 @@ protected override async Task AddedToRequestQueue(NotificationOptions model, Mob

// Get admin devices
var playerIds = await GetAdmins();
await Send(playerIds, notification, settings, model);
await Send(playerIds, notification);
}

protected override async Task RequestDeclined(NotificationOptions model, MobileNotificationSettings settings)
Expand All @@ -179,7 +179,7 @@ protected override async Task RequestDeclined(NotificationOptions model, MobileN
// Send to user
var playerIds = await GetUsers(model, NotificationType.RequestDeclined);
await AddSubscribedUsers(playerIds);
await Send(playerIds, notification, settings, model);
await Send(playerIds, notification);
}

protected override async Task RequestApproved(NotificationOptions model, MobileNotificationSettings settings)
Expand All @@ -201,7 +201,7 @@ protected override async Task RequestApproved(NotificationOptions model, MobileN
var playerIds = await GetUsers(model, NotificationType.RequestApproved);

await AddSubscribedUsers(playerIds);
await Send(playerIds, notification, settings, model);
await Send(playerIds, notification);
}

protected override async Task AvailableRequest(NotificationOptions model, MobileNotificationSettings settings)
Expand All @@ -225,7 +225,7 @@ protected override async Task AvailableRequest(NotificationOptions model, Mobile
var playerIds = await GetUsers(model, NotificationType.RequestAvailable);

await AddSubscribedUsers(playerIds);
await Send(playerIds, notification, settings, model);
await Send(playerIds, notification);
}

private static Dictionary<string,string> GetNotificationData(NotificationMessageContent parsed, NotificationType type)
Expand All @@ -240,7 +240,7 @@ protected override Task Send(NotificationMessage model, MobileNotificationSettin
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())
{
Expand Down Expand Up @@ -276,7 +276,7 @@ protected override async Task Test(NotificationOptions model, MobileNotification
}

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()
Expand Down Expand Up @@ -382,13 +382,15 @@ protected override async Task PartiallyAvailable(NotificationOptions model, Mobi
var notification = new NotificationMessage
{
Message = parsed.Message,
Subject = "New Request",
Subject = "Request Partially Available",
Data = GetNotificationData(parsed, NotificationType.PartiallyAvailable)
};

// Get admin devices
var playerIds = await GetAdmins();
await Send(playerIds, notification, settings, model, true);

var playerIds = await GetUsers(model, NotificationType.PartiallyAvailable);

await AddSubscribedUsers(playerIds);
await Send(playerIds, notification);
}
}
}