Serve brand assets as static files via /api/files/v1/static instead of S3
Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"go.gearno.de/kit/pg"
|
||||
"go.probo.inc/probo/packages/emails"
|
||||
@@ -60,7 +61,7 @@ func (s *Service) mailingListEmailConfig(
|
||||
organization = &coredata.Organization{}
|
||||
customDomain *coredata.CustomDomain
|
||||
logoFile = &coredata.File{}
|
||||
defaultCfg = emails.DefaultPresenterConfig(s.bucket, s.apiBaseURL.String())
|
||||
defaultCfg = emails.DefaultPresenterConfig(s.apiBaseURL.String())
|
||||
)
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(mailingListID)
|
||||
@@ -128,7 +129,7 @@ func (s *Service) presenterConfigFromTrustCenter(
|
||||
customDomain *coredata.CustomDomain,
|
||||
logoFile *coredata.File,
|
||||
) (emails.PresenterConfig, string, error) {
|
||||
cfg := emails.DefaultPresenterConfig(s.bucket, s.apiBaseURL.String())
|
||||
cfg := emails.DefaultPresenterConfig(s.apiBaseURL.String())
|
||||
|
||||
compliancePageBase := s.apiBaseURL.WithPath("/trust/" + compliancePage.ID.String())
|
||||
|
||||
@@ -149,12 +150,7 @@ func (s *Service) presenterConfigFromTrustCenter(
|
||||
cfg.BaseURL = compliancePageURL
|
||||
|
||||
if compliancePage.LogoFileID != nil && logoFile != nil && logoFile.FileKey != "" {
|
||||
cfg.SenderCompanyLogo = emails.Asset{
|
||||
Name: logoFile.FileName,
|
||||
ObjectKey: logoFile.FileKey,
|
||||
BucketName: logoFile.BucketName,
|
||||
MimeType: logoFile.MimeType,
|
||||
}
|
||||
cfg.SenderCompanyLogoPath = filepath.Join("/api/files/v1/public/", logoFile.ID.String())
|
||||
|
||||
cfg.SenderCompanyName = organization.Name
|
||||
if organization.WebsiteURL != nil {
|
||||
|
||||
@@ -722,7 +722,7 @@ func (s *Service) CreateUpdateEmails(
|
||||
return fmt.Errorf("cannot generate unsubscribe URL: %w", err)
|
||||
}
|
||||
|
||||
subject, textBody, htmlBody, err := emails.NewPresenterFromConfig(s.fm, presenterCfg, sub.FullName).
|
||||
subject, textBody, htmlBody, err := emails.NewPresenterFromConfig(presenterCfg, sub.FullName).
|
||||
RenderMailingListNews(ctx, orgName, updateTitle, updateBody, compliancePageURL, unsubscribeURL)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot render mailing list update email: %w", err)
|
||||
@@ -776,7 +776,7 @@ func (s *Service) buildConfirmationMail(
|
||||
return nil, fmt.Errorf("cannot get subscription confirmation email config: %w", err)
|
||||
}
|
||||
|
||||
subject, textBody, htmlBody, err := emails.NewPresenterFromConfig(s.fm, presenterCfg, fullName).
|
||||
subject, textBody, htmlBody, err := emails.NewPresenterFromConfig(presenterCfg, fullName).
|
||||
RenderMailingListSubscription(ctx, orgName, confirmURL, unsubscribeURL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot render subscription confirmation email: %w", err)
|
||||
@@ -807,7 +807,7 @@ func (s *Service) buildUnsubscriptionMail(
|
||||
return nil, fmt.Errorf("cannot get unsubscription email config: %w", err)
|
||||
}
|
||||
|
||||
subject, textBody, htmlBody, err := emails.NewPresenterFromConfig(s.fm, presenterCfg, fullName).
|
||||
subject, textBody, htmlBody, err := emails.NewPresenterFromConfig(presenterCfg, fullName).
|
||||
RenderMailingListUnsubscription(ctx, orgName)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot render unsubscription email: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user