Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Client.React/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Format: `## ` release headings and single-line `- ` bullets only — no bold, li

## 2026-10-04

- Fixed: if you only have one IV League app installed (NFL or college), you now get alerts for both sports there instead of missing the other sport's alerts
- Fixed: NFL notifications also arrived on the college app (and vice versa) when both were installed — each app now only gets its own sport's alerts
- Fixed: the first week-result notification run of the season sent a push for every already-finished week (Weeks 1-4) — a week's result can now only be pushed within 48 hours of that week ending, never later
- Improved: in dark mode, team logos switch to ESPN's dark-background versions (NFL and college), so logos with dark lettering like Ohio State's stay readable
Expand Down
16 changes: 16 additions & 0 deletions Server.UnitTests/NotificationDispatcherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,20 @@ await BuildDispatcher(isDevelopment: false, railwayEnvironmentName: "production"
await _pushSender.Received(1).SendAsync(Arg.Is<PushSubscription>(s => s.Endpoint == "https://push.example/old"), Arg.Any<PushPayload>(), Arg.Any<CancellationToken>());
await _pushSender.DidNotReceive().SendAsync(Arg.Is<PushSubscription>(s => s.Endpoint == excluded), Arg.Any<PushPayload>(), Arg.Any<CancellationToken>());
}

// Many users install only one app but are in both sports' leagues — a push must never be
// dropped just because the user has no app for that sport (a real NFL alert was, 2026-10-04).
[Fact]
public async Task DispatchAsync_UserWithOnlyTheOtherSportsApp_StillGetsThePush()
{
_preferencesService.GetAsync("user-1").Returns(new NotificationPreferencesDto { NotifyWeekResult = true });
_subscriptionService.GetForUserAsync("user-1").Returns([
new PushSubscription { Id = 1, UserId = "user-1", Endpoint = "https://push.example/cfb", P256dh = "p", Auth = "a", Sport = LeagueType.Cfb },
]);

await BuildDispatcher(isDevelopment: false, railwayEnvironmentName: "production")
.DispatchAsync("user-1", p => p.NotifyWeekResult, new PushPayload("T", "B", Sport: LeagueType.Nfl));

await _pushSender.Received(1).SendAsync(Arg.Is<PushSubscription>(s => s.Endpoint == "https://push.example/cfb"), Arg.Any<PushPayload>(), Arg.Any<CancellationToken>());
}
}
9 changes: 6 additions & 3 deletions Server/Services/NotificationDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ public async Task DispatchAsync(string userId, Func<NotificationPreferencesDto,
var preferences = await preferencesService.GetAsync(userId);
if (!isEnabled(preferences)) return;

// Only the app for this push's sport (NFL vs CFB host) — plus devices saved before sport was
// tracked, which keep getting everything until their app re-registers.
var subscriptions = (await subscriptionService.GetForUserAsync(userId))
// Prefer the app for this push's sport (NFL vs CFB host), plus untagged devices, so a user
// with both apps gets it once, in the right one. A user with only the other sport's app
// still gets it there — a push is never dropped for lack of a matching app.
var allSubscriptions = await subscriptionService.GetForUserAsync(userId);
var matching = allSubscriptions
.Where(s => payload.Sport is null || s.Sport is null || s.Sport == payload.Sport)
.ToList();
var subscriptions = matching.Count > 0 ? matching : allSubscriptions;
if (subscriptions.Count == 0) return;

if (!DeploymentEnvironment.IsProduction(environment))
Expand Down