Files
warmbly/internal/app/unibox/storage.go
T

32 lines
710 B
Go

package unibox
import (
"context"
"github.com/google/uuid"
"github.com/warmbly/warmbly/internal/config"
"github.com/warmbly/warmbly/internal/pkg/emsg"
)
// GetBody reads a message's full body blob. The key must match what the
// worker's StoreBody writes; any other key finds nothing and the message
// degrades to its one-line snippet.
func (s *uniboxService) GetBody(
ctx context.Context,
userID, emailID, id uuid.UUID,
) (*emsg.EmailBlob, error) {
key := config.StorageEndpointEmailBody(userID, emailID, id)
body, err := s.blob.Get(ctx, key)
if err != nil {
return nil, err
}
defer body.Close()
obj, err := emsg.DecodeBinary(body)
if err != nil {
return nil, err
}
return obj, nil
}