Alerting: Add image url or file attachment to email notifications. (#49381)

If an image token is present in an alert instance, the email notifier will attempt to find a public URL for the image token. If found, it will add that to the email as the `ImageLink` field. If only local file data is available, the notifier will attach the file to the outgoing email using the `EmbeddedImage` field.
This commit is contained in:
Joe Blubaugh
2022-05-23 23:08:28 +08:00
committed by GitHub
parent 5a3cd45f79
commit ccd160a75e
6 changed files with 61 additions and 4 deletions

View File

@@ -41,6 +41,8 @@ type ImageStore interface {
GetURL(ctx context.Context, token string) (string, error)
GetFilepath(ctx context.Context, token string) (string, error)
// Returns an io.ReadCloser that reads out the image data for the provided
// token, if available. May return ErrImageNotFound.
GetData(ctx context.Context, token string) (io.ReadCloser, error)
@@ -99,6 +101,14 @@ func (st *DBstore) GetURL(ctx context.Context, token string) (string, error) {
return img.URL, nil
}
func (st *DBstore) GetFilepath(ctx context.Context, token string) (string, error) {
img, err := st.GetImage(ctx, token)
if err != nil {
return "", err
}
return img.Path, nil
}
func (st *DBstore) GetData(ctx context.Context, token string) (io.ReadCloser, error) {
// TODO: Should we support getting data from image.URL? One could configure
// the system to upload to S3 while still reading data for notifiers like