feat(document): getThumbnailUrl composes /api/documents/{id}/thumbnail when key present

The no-cache-buster branch covers documents whose thumbnail key is set
but whose thumbnailGeneratedAt is still null — which only happens in
the narrow window between the key being persisted and the async worker
stamping the timestamp (#309).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-23 21:52:09 +02:00
parent 096f66eb15
commit df260d5c64
2 changed files with 18 additions and 1 deletions

View File

@@ -133,6 +133,7 @@ public class Document {
private Set<TrainingLabel> trainingLabels = new HashSet<>();
public String getThumbnailUrl() {
return null;
if (thumbnailKey == null) return null;
return "/api/documents/" + id + "/thumbnail";
}
}

View File

@@ -20,4 +20,20 @@ class DocumentTest {
assertThat(doc.getThumbnailUrl()).isNull();
}
@Test
void getThumbnailUrl_omitsCacheBuster_whenThumbnailKeyPresentButGeneratedAtNull() {
UUID id = UUID.fromString("11111111-2222-3333-4444-555555555555");
Document doc = Document.builder()
.id(id)
.title("Brief")
.originalFilename("brief.pdf")
.status(DocumentStatus.UPLOADED)
.thumbnailKey("thumbnails/" + id + ".jpg")
.thumbnailGeneratedAt(null)
.build();
assertThat(doc.getThumbnailUrl())
.isEqualTo("/api/documents/" + id + "/thumbnail");
}
}