fix 401 endpoint - signed endpoint

This commit is contained in:
m
2026-07-16 08:05:40 +02:00
parent 10c07d2946
commit 073934be4f
3 changed files with 180 additions and 17 deletions
+42
View File
@@ -238,6 +238,48 @@ func (s *FileService) GetThumbnailStoragePath(id string) (string, error) {
return t.StorageKey, nil
}
func (s *FileService) GetBestThumbnail(fileID, preferredLabel string) *model.Thumbnail {
dbThumbnails, err := s.queries.GetThumbnailsByFileID(context.Background(), fileID)
if err != nil || len(dbThumbnails) == 0 {
return nil
}
var fallback *model.Thumbnail
for _, t := range dbThumbnails {
if t.PageNumber != 1 {
continue
}
if t.ResolutionLabel == preferredLabel {
return &model.Thumbnail{
ID: t.ID,
FileID: t.FileID,
PageNumber: int(t.PageNumber),
ResolutionLabel: t.ResolutionLabel,
Width: int(t.Width),
Height: int(t.Height),
StorageKey: t.StorageKey,
MimeType: t.MimeType,
CreatedAt: t.CreatedAt.String(),
}
}
if fallback == nil {
fallback = &model.Thumbnail{
ID: t.ID,
FileID: t.FileID,
PageNumber: int(t.PageNumber),
ResolutionLabel: t.ResolutionLabel,
Width: int(t.Width),
Height: int(t.Height),
StorageKey: t.StorageKey,
MimeType: t.MimeType,
CreatedAt: t.CreatedAt.String(),
}
}
}
return fallback
}
func dbToModel(f db.File, dbTags []db.Tag) model.File {
tags := make([]model.Tag, len(dbTags))
for i, t := range dbTags {