Revert "Alerting: Refactor the ImageStore/Provider to provide image URL/bytes" (#69265)

Revert "Alerting: Refactor the ImageStore/Provider to provide image URL/bytes (#67693)"

This reverts commit 72a187b0be.
This commit is contained in:
Alexander Weaver
2023-05-30 11:33:33 -05:00
committed by GitHub
parent 27c18b8c0c
commit 0ed5d3bdf2
10 changed files with 31 additions and 365 deletions

View File

@@ -31,10 +31,6 @@ type ImageStore interface {
// SaveImage saves the image or returns an error.
SaveImage(ctx context.Context, img *models.Image) error
// URLExists takes a URL and returns a boolean indicating whether or not
// we have an image for that URL.
URLExists(ctx context.Context, url string) (bool, error)
}
type ImageAdminStore interface {
@@ -79,19 +75,6 @@ func (st DBstore) GetImageByURL(ctx context.Context, url string) (*models.Image,
return &image, nil
}
func (st DBstore) URLExists(ctx context.Context, url string) (bool, error) {
var exists bool
err := st.SQLStore.WithDbSession(ctx, func(sess *db.Session) error {
ok, err := sess.Table("alert_image").Where("url = ? AND expires_at > ?", url, TimeNow().UTC()).Exist()
if err != nil {
return err
}
exists = ok
return nil
})
return exists, err
}
func (st DBstore) GetImages(ctx context.Context, tokens []string) ([]models.Image, []string, error) {
var images []models.Image
if err := st.SQLStore.WithDbSession(ctx, func(sess *db.Session) error {