fix: enforce one active logical album grant

This commit is contained in:
Leon Tonhäuser committed 2026-08-10 12:14:38 +02:00
1 parent 74ab2eb85f
commit c400167b8f
9 files changed
+577 -45

No files matched your search

+5 -3
View File
@@ -301,13 +301,13 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents",
"insert into album_grants (editorial_account_id, immich_album_id) values ($1, $2)",
[editorialId, "new-invalid-album"],
),
).rejects.toThrow(/album_grants_canonical_immich_album_id_check/);
).rejects.toThrow(/album_grants_immich_album_id_uuid_check/);
await expect(
testDb.pool.query(
"update album_grants set revoked_at = now() where immich_album_id = $1",
[dirtyAlbumId],
),
).rejects.toThrow(/album_grants_canonical_immich_album_id_check/);
).rejects.toThrow(/album_grants_immich_album_id_uuid_check/);
const grantService = createAlbumGrantService({
repository: createAlbumGrantRepository(testDb.database),
@@ -336,7 +336,9 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents",
[validAlbumId],
);
expect(canonicalGrantRows.rows).toHaveLength(2);
expect(canonicalGrantRows.rows.every((row) => row.immich_album_id === validAlbumId)).toBe(true);
expect(canonicalGrantRows.rows.map((row) => row.immich_album_id).sort()).toEqual(
[validAlbumId.toUpperCase(), validAlbumId].sort(),
);
expect(canonicalGrantRows.rows.every((row) => row.revoked_at !== null)).toBe(true);
await grantService.grantAlbum({