mirror of
https://github.com/warmbly/warmbly.git
synced 2026-11-29 08:06:27 +00:00
Seven call sites stop reaching through the embedded *s3.Client and instead use the high-level storage.Store methods. Same runtime behavior on the AWS path; opens the door to the Filesystem backend for self-hosters. avatar.go retains an S3-specific path for public-ACL + cache-control on uploaded avatars and falls back to ServiceUnavailable on non-S3 backends. A future PublicStore interface could clean that up. unibox/storage.go GetBody now propagates the emsg.DecodeBinary error that the original code dropped on the floor.
27 lines
664 B
Go
27 lines
664 B
Go
package wmail
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/warmbly/warmbly/internal/config"
|
|
"github.com/warmbly/warmbly/internal/pkg/emsg"
|
|
)
|
|
|
|
func (c *WMail) Exists(ctx context.Context, messageID uuid.UUID) (bool, error) {
|
|
key := config.StorageEndpointEmailBody(c.UserID, c.ID, messageID)
|
|
return c.Storage.Has(ctx, key)
|
|
}
|
|
|
|
func (c *WMail) StoreBody(ctx context.Context, emailMessageID uuid.UUID, data *emsg.EmailBlob) error {
|
|
bytedata, err := data.EncodeBinary()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
key := config.StorageEndpointEmailBody(c.UserID, c.ID, emailMessageID)
|
|
|
|
return c.Storage.Put(ctx, key, bytes.NewReader(bytedata), "")
|
|
}
|