From 32068f7cf6ce6079b53b1e75ff2a31f5a6c5efe3 Mon Sep 17 00:00:00 2001 From: tgiachi Date: Wed, 11 Nov 2026 15:02:28 +0100 Subject: [PATCH] fix(listening): report a deleted account first and document one event per play - fix: a listen from a deleted account is answered 401 before the track or the duration is looked at, so a client that signs out on 401 does it whatever else is wrong with the request (UserExists on the store) - docs: one event per play, sent when the play ends or is abandoned, with one idempotency key per play. An event cannot be upgraded afterwards: a key that was already used is ignored even if the type or duration differ, and a new key would count the same play twice. The README no longer says to report at 20 seconds, which led straight into that trap, and no longer hard-codes the minimum - test: the SQL filter at exactly the threshold and just under it, the order of events within the same second, the order of checks for a deleted account --- README.md | 2 +- internal/api/http/auth_test.go | 15 +++++-- internal/api/openapi/openapi.yaml | 13 ++++-- internal/listening/listening.go | 12 ++++++ internal/listening/listening_test.go | 25 ++++++++++++ internal/storage/listening.go | 9 +++++ internal/storage/repos_test.go | 59 ++++++++++++++++++++++++++++ 7 files changed, 126 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9bfe5bb..6891ed8 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ curl -s -o track.audio -H "$AUTH" $BASE/tracks/$TRACK/stream A browser `