fix(push): reinstalled app replaces its old subscription; devices listed and removable
MindSift CI & Docker Release / Build, Test in Container & Push (push) Failing after 2m8s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Failing after 2m8s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f76b0f34ff
commit
5b636b66e2
9 files changed
+123
-14
No files matched your search
@@ -77,3 +77,24 @@ func TestPushDigestText(t *testing.T) {
|
||||
t.Fatalf("many: %+v", many)
|
||||
}
|
||||
}
|
||||
|
||||
// A reinstalled app registers a new subscription and names the old one: it is dropped, not counted twice
|
||||
func TestPushResubscribeReplacesOldDevice(t *testing.T) {
|
||||
srv, store, _ := setupTestServer(t)
|
||||
router := srv.Router()
|
||||
me, token := newTestUser(t, store, "reinstall@example.com")
|
||||
sub := func(endpoint, replaces string) int {
|
||||
body := `{"endpoint":"` + endpoint + `","keys":{"p256dh":"k","auth":"a"},"device":"Chrome auf Android","replaces":"` + replaces + `"}`
|
||||
return sessionCall(router, http.MethodPost, "/api/v1/push/subscribe", token, body, "").Code
|
||||
}
|
||||
if code := sub("https://fcm.googleapis.com/fcm/send/alt", ""); code != http.StatusOK {
|
||||
t.Fatalf("subscribe: %d", code)
|
||||
}
|
||||
if code := sub("https://fcm.googleapis.com/fcm/send/neu", "https://fcm.googleapis.com/fcm/send/alt"); code != http.StatusOK {
|
||||
t.Fatalf("resubscribe: %d", code)
|
||||
}
|
||||
subs, _ := store.PushSubscriptions(me.ID)
|
||||
if len(subs) != 1 || subs[0].Endpoint != "https://fcm.googleapis.com/fcm/send/neu" {
|
||||
t.Fatalf("old installation must be replaced, got %+v", subs)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user