feat: new-music notices come from the scanner; request notices and the original specs go
release / web (push) Failing after 1m29s
release / go (push) Successful in 1m55s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 4m22s
release / android (push) Successful in 4m57s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 4m23s
release / web (push) Failing after 1m29s
release / go (push) Successful in 1m55s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 4m22s
release / android (push) Successful in 4m57s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 4m23s
Request notifications (approved, declined, completed, pending) are removed
along with the request flow that produced them. A new_music kind takes the
"new music arrived" slot: when a scan or a watcher batch finishes, the
scanner claims every album not yet announced (albums.announced_at) and tells
every user about the ones that are new: an album with a track on disk and
no track older than itself. The first import into an empty library, and an
album formed only by retagging tracks already held, announce nothing. One
notice per scan, carrying up to 50 albums and the total; it is never
coalesced, so a notice already emailed can't quietly absorb later arrivals.
It feeds the daily summary email, grouped by artist. Defaults: inbox and
email on, phone off.
Migration 0103 deletes request-kind notification rows and prefs, swaps the
kind CHECKs to new_music, and adds albums.announced_at with every album
held marked announced, so the first scan after it announces nothing old.
Web and Android: labels, the Android "Requests" settings section becomes
"New music", the shade channel your_requests becomes new_music (the old one
is deleted at startup), and "/" opens Home in the app. TrackLabel moves to
the notifications package. docs/smart-music-{server,client}-spec.md are
deleted per the operator; an Android comment loses the word "exchanges".
Grimoire #7666, #7671.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,8 +28,8 @@ func allEmail() map[Kind]bool {
|
||||
}
|
||||
|
||||
func TestPlanUser_BatchWindow(t *testing.T) {
|
||||
first := item(KindRequestApproved, t0)
|
||||
later := item(KindRequestRejected, t0.Add(40*time.Minute))
|
||||
first := item(KindQuarantineFlagged, t0)
|
||||
later := item(KindTracksMissing, t0.Add(40*time.Minute))
|
||||
cases := []struct {
|
||||
name string
|
||||
now time.Time
|
||||
@@ -63,7 +63,7 @@ func TestPlanUser_QuietBatchSendsNothing(t *testing.T) {
|
||||
func TestPlanUser_SummaryHourInUserTimezone(t *testing.T) {
|
||||
ny, err := time.LoadLocation("America/New_York")
|
||||
require.NoError(t, err)
|
||||
arrived := []pendingItem{item(KindRequestCompleted, time.Date(2026, 7, 1, 3, 0, 0, 0, time.UTC))}
|
||||
arrived := []pendingItem{item(KindNewMusic, time.Date(2026, 7, 1, 3, 0, 0, 0, time.UTC))}
|
||||
// 09:00 in New York in July is 13:00 UTC (EDT, UTC-4).
|
||||
cases := []struct {
|
||||
name string
|
||||
@@ -90,7 +90,7 @@ func TestPlanUser_SummaryHourInUserTimezone(t *testing.T) {
|
||||
func TestPlanUser_SummaryAcrossDST(t *testing.T) {
|
||||
ny, err := time.LoadLocation("America/New_York")
|
||||
require.NoError(t, err)
|
||||
arrived := []pendingItem{item(KindRequestCompleted, time.Date(2026, 11, 1, 0, 0, 0, 0, time.UTC))}
|
||||
arrived := []pendingItem{item(KindNewMusic, time.Date(2026, 11, 1, 0, 0, 0, 0, time.UTC))}
|
||||
// Clocks go back on 1 November 2026: 09:00 the day before is 13:00 UTC
|
||||
// (EDT), and 09:00 that day is 14:00 UTC (EST).
|
||||
before := groupState{LastSentAt: time.Date(2026, 10, 31, 13, 0, 0, 0, time.UTC)}
|
||||
@@ -102,7 +102,7 @@ func TestPlanUser_SummaryAcrossDST(t *testing.T) {
|
||||
// Spring forward, 8 March 2026: 02:00 does not exist. A summary hour of
|
||||
// 2 still goes out that day, once.
|
||||
gap := EmailSettings{SummaryHour: 2, BatchWindowMinutes: 60}
|
||||
spring := []pendingItem{item(KindRequestCompleted, time.Date(2026, 3, 8, 0, 0, 0, 0, time.UTC))}
|
||||
spring := []pendingItem{item(KindNewMusic, time.Date(2026, 3, 8, 0, 0, 0, 0, time.UTC))}
|
||||
at := time.Date(2026, 3, 8, 9, 0, 0, 0, time.UTC) // 05:00 EDT
|
||||
p = planUser(at, gap, ny, spring, allEmail(), groupState{}, groupState{LastSentAt: time.Date(2026, 3, 7, 7, 0, 0, 0, time.UTC)})
|
||||
require.True(t, p.SummaryDue)
|
||||
@@ -112,10 +112,10 @@ func TestPlanUser_SummaryAcrossDST(t *testing.T) {
|
||||
|
||||
func TestPlanUser_EmailOffAndStaleItemsAreSkippedNotSent(t *testing.T) {
|
||||
off := allEmail()
|
||||
off[KindRequestRejected] = false
|
||||
off[KindTracksMissing] = false
|
||||
items := []pendingItem{
|
||||
item(KindRequestRejected, t0),
|
||||
item(KindRequestApproved, t0.Add(-8*24*time.Hour)),
|
||||
item(KindTracksMissing, t0),
|
||||
item(KindQuarantineFlagged, t0.Add(-8*24*time.Hour)),
|
||||
}
|
||||
p := planUser(t0.Add(2*time.Hour), digestCfg, time.UTC, items, off, groupState{}, groupState{})
|
||||
require.Len(t, p.Skip, 2)
|
||||
@@ -132,15 +132,14 @@ func TestRetryDelay_DoublesToACap(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRenderDigest_SummaryGroupsByArtist(t *testing.T) {
|
||||
arrival := func(p Payload) pendingItem {
|
||||
b, _ := json.Marshal(p.Map())
|
||||
return pendingItem{Kind: KindRequestCompleted, Payload: b}
|
||||
scan := func(albums ...Arrival) pendingItem {
|
||||
b, _ := json.Marshal(Payload{Count: int64(len(albums)), Albums: albums}.Map())
|
||||
return pendingItem{Kind: KindNewMusic, Payload: b}
|
||||
}
|
||||
items := []pendingItem{
|
||||
arrival(Payload{Name: "Moe Shop – WWW", Artist: "Moe Shop", Title: "WWW", AlbumID: "al-1"}),
|
||||
arrival(Payload{Name: "Boards of Canada", Artist: "Boards of Canada", ArtistID: "ar-2"}),
|
||||
arrival(Payload{Name: "Moe Shop – Pure", Artist: "Moe Shop", Title: "Pure", AlbumID: "al-3"}),
|
||||
arrival(Payload{Name: "Tycho – Awake"}), // stored before Artist was recorded
|
||||
scan(Arrival{Artist: "Moe Shop", Title: "WWW", ArtistID: "ar-1", AlbumID: "al-1"},
|
||||
Arrival{Artist: "Boards of Canada", Title: "Geogaddi", AlbumID: "al-2"}),
|
||||
scan(Arrival{Artist: "Moe Shop", Title: "Pure", ArtistID: "ar-1", AlbumID: "al-3"}),
|
||||
}
|
||||
e, err := renderDigest(EmailSummary, "alice", items, "https://music.example/")
|
||||
require.NoError(t, err)
|
||||
@@ -148,12 +147,12 @@ func TestRenderDigest_SummaryGroupsByArtist(t *testing.T) {
|
||||
|
||||
moe := strings.Index(e.Text, "Moe Shop")
|
||||
require.GreaterOrEqual(t, moe, 0)
|
||||
require.Equal(t, moe, strings.LastIndex(e.Text, "Moe Shop\n"), "one heading per artist")
|
||||
require.Equal(t, moe, strings.LastIndex(e.Text, "Moe Shop\n"), "one heading per artist, across scans")
|
||||
require.Less(t, moe, strings.Index(e.Text, "Boards of Canada"), "artists in the order they arrived")
|
||||
require.Contains(t, e.Text, "Moe Shop\n https://music.example/artists/ar-1")
|
||||
require.Contains(t, e.Text, " - WWW\n https://music.example/albums/al-1")
|
||||
require.Contains(t, e.Text, " - Pure\n https://music.example/albums/al-3")
|
||||
require.Contains(t, e.Text, "Boards of Canada\n https://music.example/artists/ar-2")
|
||||
require.Contains(t, e.Text, "Tycho\n - Awake")
|
||||
require.Contains(t, e.Text, " - Geogaddi\n https://music.example/albums/al-2")
|
||||
require.Contains(t, e.Text, "https://music.example/settings/notifications")
|
||||
require.Contains(t, e.HTML, `<a href="https://music.example/albums/al-1"`)
|
||||
}
|
||||
@@ -161,18 +160,18 @@ func TestRenderDigest_SummaryGroupsByArtist(t *testing.T) {
|
||||
func TestRenderDigest_BatchListsEachItemAndEscapesHTML(t *testing.T) {
|
||||
b, _ := json.Marshal(Payload{Name: "<script>x</script>", Reason: "dup"}.Map())
|
||||
items := []pendingItem{
|
||||
{Kind: KindRequestApproved, Payload: []byte(`{"name":"WWW"}`)},
|
||||
{Kind: KindRequestRejected, Payload: b},
|
||||
{Kind: KindQuarantineFlagged, Payload: []byte(`{"name":"WWW","actor":"Ann"}`)},
|
||||
{Kind: KindQuarantineFlagged, Payload: b},
|
||||
}
|
||||
e, err := renderDigest(EmailBatch, "alice", items, "")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "Minstrel: 2 updates", e.Subject)
|
||||
require.Contains(t, e.Text, "- Request approved\n WWW is on its way.")
|
||||
require.Contains(t, e.Text, "- Track flagged\n Ann flagged WWW.")
|
||||
require.NotContains(t, e.Text, "http", "no public address: no links")
|
||||
require.Contains(t, e.Text, "Settings → Notifications")
|
||||
require.NotContains(t, e.HTML, "<script>")
|
||||
|
||||
one, err := renderDigest(EmailBatch, "alice", items[:1], "")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "Minstrel: Request approved", one.Subject)
|
||||
require.Equal(t, "Minstrel: Track flagged", one.Subject)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user