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:
@@ -129,7 +129,7 @@ func (s AccountService) ChangeEmail(ctx context.Context, identityID gid.GID, req
|
||||
return fmt.Errorf("cannot update identity: %w", err)
|
||||
}
|
||||
|
||||
emailPresenter := emails.NewPresenter(s.fm, s.bucket, s.baseURL, identity.FullName)
|
||||
emailPresenter := emails.NewPresenter(s.baseURL, identity.FullName)
|
||||
|
||||
subject, textBody, htmlBody, err := emailPresenter.RenderConfirmEmail(ctx, "/auth/verify-email", confirmationToken)
|
||||
if err != nil {
|
||||
|
||||
@@ -314,7 +314,7 @@ func (s AuthService) SendPasswordResetInstructionByEmail(
|
||||
return fmt.Errorf("cannot load identity: %w", err)
|
||||
}
|
||||
|
||||
emailPresenter := emails.NewPresenter(s.fm, s.bucket, s.baseURL, identity.FullName)
|
||||
emailPresenter := emails.NewPresenter(s.baseURL, identity.FullName)
|
||||
|
||||
subject, textBody, htmlBody, err := emailPresenter.RenderPasswordReset(
|
||||
ctx,
|
||||
@@ -387,7 +387,7 @@ func (s AuthService) CreateIdentityWithPassword(
|
||||
return nil, nil, fmt.Errorf("cannot generate confirmation token: %w", err)
|
||||
}
|
||||
|
||||
emailPresenter := emails.NewPresenter(s.fm, s.bucket, s.baseURL, req.FullName)
|
||||
emailPresenter := emails.NewPresenter(s.baseURL, req.FullName)
|
||||
|
||||
subject, textBody, htmlBody, err := emailPresenter.RenderConfirmEmail(ctx, "/auth/verify-email", confirmationToken)
|
||||
if err != nil {
|
||||
@@ -594,7 +594,7 @@ func (s AuthService) SendMagicLink(ctx context.Context, req *SendMagicLinkReques
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
emailPresenterCfg := emails.DefaultPresenterConfig(s.bucket, s.baseURL)
|
||||
emailPresenterCfg := emails.DefaultPresenterConfig(s.baseURL)
|
||||
|
||||
if req.CompliancePageID != nil {
|
||||
var err error
|
||||
@@ -605,7 +605,7 @@ func (s AuthService) SendMagicLink(ctx context.Context, req *SendMagicLinkReques
|
||||
}
|
||||
}
|
||||
|
||||
emailPresenter := emails.NewPresenterFromConfig(s.fm, emailPresenterCfg, fullName)
|
||||
emailPresenter := emails.NewPresenterFromConfig(emailPresenterCfg, fullName)
|
||||
|
||||
subject, textBody, htmlBody, err := emailPresenter.RenderMagicLink(
|
||||
ctx,
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"go.gearno.de/kit/pg"
|
||||
@@ -77,7 +78,7 @@ func (s *CompliancePageService) GenerateLogoURL(
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
presignedURL, err := s.fm.GenerateFileUrl(ctx, file, expiresIn)
|
||||
presignedURL, err := s.fm.GenerateFileURL(ctx, file, expiresIn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot generate file URL: %w", err)
|
||||
}
|
||||
@@ -91,7 +92,7 @@ func (s *CompliancePageService) EmailPresenterConfig(ctx context.Context, compli
|
||||
organization = &coredata.Organization{}
|
||||
customDomain *coredata.CustomDomain
|
||||
logoFile = &coredata.File{}
|
||||
emailPresenterCfg = emails.DefaultPresenterConfig(s.bucket, s.baseURL)
|
||||
emailPresenterCfg = emails.DefaultPresenterConfig(s.baseURL)
|
||||
)
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(compliancePageID)
|
||||
@@ -152,14 +153,7 @@ func (s *CompliancePageService) EmailPresenterConfig(ctx context.Context, compli
|
||||
}
|
||||
|
||||
// If logo exists, then we will brand the emails with the org as a sender
|
||||
|
||||
emailPresenterCfg.SenderCompanyLogo = emails.Asset{
|
||||
Name: logoFile.FileName,
|
||||
ObjectKey: logoFile.FileKey,
|
||||
BucketName: logoFile.BucketName,
|
||||
MimeType: logoFile.MimeType,
|
||||
}
|
||||
|
||||
emailPresenterCfg.SenderCompanyLogoPath = filepath.Join("/api/files/v1/public/", logoFile.ID.String())
|
||||
emailPresenterCfg.SenderCompanyName = organization.Name
|
||||
|
||||
if organization.WebsiteURL != nil {
|
||||
|
||||
@@ -514,7 +514,7 @@ func (s *OrganizationService) InviteUser(
|
||||
return fmt.Errorf("cannot generate invitation token: %w", err)
|
||||
}
|
||||
|
||||
emailPresenter := emails.NewPresenter(s.fm, s.bucket, s.baseURL, profile.FullName)
|
||||
emailPresenter := emails.NewPresenter(s.baseURL, profile.FullName)
|
||||
|
||||
subject, textBody, htmlBody, err := emailPresenter.RenderInvitation(
|
||||
ctx,
|
||||
@@ -1409,7 +1409,7 @@ func (s OrganizationService) GenerateLogoURL(
|
||||
return nil, fmt.Errorf("cannot generate logo URL: %w", err)
|
||||
}
|
||||
|
||||
presignedURL, err := s.fm.GenerateFileUrl(ctx, file, expiresIn)
|
||||
presignedURL, err := s.fm.GenerateFileURL(ctx, file, expiresIn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot generate file URL: %w", err)
|
||||
}
|
||||
@@ -1455,7 +1455,7 @@ func (s OrganizationService) GenerateHorizontalLogoURL(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
presignedURL, err := s.fm.GenerateFileUrl(ctx, file, expiresIn)
|
||||
presignedURL, err := s.fm.GenerateFileURL(ctx, file, expiresIn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot generate file URL: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user