Add timestamp suffix to all image urls (#1200)

This commit is contained in:
InfiniteTF
2021-03-13 01:49:20 +01:00
committed by GitHub
parent a619b9dd48
commit ecac7a8013
14 changed files with 63 additions and 50 deletions

View File

@@ -1,25 +1,28 @@
package urlbuilders
import (
"github.com/stashapp/stash/pkg/models"
"strconv"
)
type ImageURLBuilder struct {
BaseURL string
ImageID string
BaseURL string
ImageID string
UpdatedAt string
}
func NewImageURLBuilder(baseURL string, imageID int) ImageURLBuilder {
func NewImageURLBuilder(baseURL string, image *models.Image) ImageURLBuilder {
return ImageURLBuilder{
BaseURL: baseURL,
ImageID: strconv.Itoa(imageID),
BaseURL: baseURL,
ImageID: strconv.Itoa(image.ID),
UpdatedAt: strconv.FormatInt(image.UpdatedAt.Timestamp.Unix(), 10),
}
}
func (b ImageURLBuilder) GetImageURL() string {
return b.BaseURL + "/image/" + b.ImageID + "/image"
return b.BaseURL + "/image/" + b.ImageID + "/image?" + b.UpdatedAt
}
func (b ImageURLBuilder) GetThumbnailURL() string {
return b.BaseURL + "/image/" + b.ImageID + "/thumbnail"
return b.BaseURL + "/image/" + b.ImageID + "/thumbnail?" + b.UpdatedAt
}