Skip to content

Commit

Permalink
fix(notifications): Fixed the Partially TV notifications going to the…
Browse files Browse the repository at this point in the history
… admin #4797 (#4799)
  • Loading branch information
tidusjar authored Nov 14, 2022
1 parent 987ec5a commit bcb3e7f
Showing 1 changed file with 17 additions and 15 deletions.
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);
}
}
}

0 comments on commit bcb3e7f

Please sign in to comment.