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:
@@ -126,6 +126,7 @@ public class Document {
|
|||||||
private Set<TrainingLabel> trainingLabels = new HashSet<>();
|
private Set<TrainingLabel> trainingLabels = new HashSet<>();
|
||||||
|
|
||||||
public String getThumbnailUrl() {
|
public String getThumbnailUrl() {
|
||||||
return null;
|
if (thumbnailKey == null) return null;
|
||||||
|
return "/api/documents/" + id + "/thumbnail";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,4 +20,20 @@ class DocumentTest {
|
|||||||
|
|
||||||
assertThat(doc.getThumbnailUrl()).isNull();
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user