Rename portal service locals to portal

Use portal and portalID in management portal_service helpers and align
error messages with the Compliance Portal product name.

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-07-21 13:33:11 +02:00
parent d0090e8c65
commit 8402e0c31e

View File

@@ -133,26 +133,26 @@ func (req *UpdateBrandRequest) Validate() error {
func (s *Service) Get( func (s *Service) Get(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, portalID gid.GID,
) (*coredata.CompliancePortal, error) { ) (*coredata.CompliancePortal, error) {
var compliancePage *coredata.CompliancePortal var portal *coredata.CompliancePortal
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
compliancePage = &coredata.CompliancePortal{} portal = &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := portal.LoadByID(ctx, conn, scope, portalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
return nil return nil
}, },
) )
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot load compliance page: %w", err) return nil, fmt.Errorf("cannot load compliance portal: %w", err)
} }
return compliancePage, nil return portal, nil
} }
func (s *Service) GetByOrganizationID( func (s *Service) GetByOrganizationID(
@@ -160,14 +160,14 @@ func (s *Service) GetByOrganizationID(
scope coredata.Scoper, scope coredata.Scoper,
organizationID gid.GID, organizationID gid.GID,
) (*coredata.CompliancePortal, error) { ) (*coredata.CompliancePortal, error) {
var compliancePage *coredata.CompliancePortal var portal *coredata.CompliancePortal
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
compliancePage = &coredata.CompliancePortal{} portal = &coredata.CompliancePortal{}
if err := compliancePage.LoadByOrganizationID(ctx, conn, scope, organizationID); err != nil { if err := portal.LoadByOrganizationID(ctx, conn, scope, organizationID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
return nil return nil
@@ -177,7 +177,7 @@ func (s *Service) GetByOrganizationID(
return nil, err return nil, err
} }
return compliancePage, nil return portal, nil
} }
func (s *Service) Update( func (s *Service) Update(
@@ -190,40 +190,40 @@ func (s *Service) Update(
} }
var ( var (
compliancePage *coredata.CompliancePortal portal *coredata.CompliancePortal
file *coredata.File file *coredata.File
) )
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, conn pg.Tx) error { func(ctx context.Context, conn pg.Tx) error {
compliancePage = &coredata.CompliancePortal{} portal = &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, req.ID); err != nil { if err := portal.LoadByID(ctx, conn, scope, req.ID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
if req.Active != nil { if req.Active != nil {
compliancePage.Active = *req.Active portal.Active = *req.Active
} }
if req.Slug != nil { if req.Slug != nil {
compliancePage.Slug = *req.Slug portal.Slug = *req.Slug
} }
if req.SearchEngineIndexing != nil { if req.SearchEngineIndexing != nil {
compliancePage.SearchEngineIndexing = *req.SearchEngineIndexing portal.SearchEngineIndexing = *req.SearchEngineIndexing
} }
if req.Title != nil { if req.Title != nil {
compliancePage.Title = *req.Title portal.Title = *req.Title
} }
if req.Description != nil { if req.Description != nil {
compliancePage.Description = *req.Description portal.Description = *req.Description
} }
if req.WebsiteURL != nil { if req.WebsiteURL != nil {
compliancePage.WebsiteURL = *req.WebsiteURL portal.WebsiteURL = *req.WebsiteURL
} }
if req.Email != nil { if req.Email != nil {
@@ -233,22 +233,22 @@ func (s *Service) Update(
} }
} }
compliancePage.Email = *req.Email portal.Email = *req.Email
} }
if req.HeadquarterAddress != nil { if req.HeadquarterAddress != nil {
compliancePage.HeadquarterAddress = *req.HeadquarterAddress portal.HeadquarterAddress = *req.HeadquarterAddress
} }
compliancePage.UpdatedAt = time.Now() portal.UpdatedAt = time.Now()
if err := compliancePage.Update(ctx, conn, scope); err != nil { if err := portal.Update(ctx, conn, scope); err != nil {
return fmt.Errorf("cannot update compliance page: %w", err) return fmt.Errorf("cannot update compliance portal: %w", err)
} }
if compliancePage.NonDisclosureAgreementFileID != nil { if portal.NonDisclosureAgreementFileID != nil {
file = &coredata.File{} file = &coredata.File{}
if err := file.LoadByID(ctx, conn, scope, *compliancePage.NonDisclosureAgreementFileID); err != nil { if err := file.LoadByID(ctx, conn, scope, *portal.NonDisclosureAgreementFileID); err != nil {
return fmt.Errorf("cannot load file: %w", err) return fmt.Errorf("cannot load file: %w", err)
} }
} }
@@ -260,7 +260,7 @@ func (s *Service) Update(
return nil, nil, err return nil, nil, err
} }
return compliancePage, file, nil return portal, file, nil
} }
func (s *Service) UploadNDA( func (s *Service) UploadNDA(
@@ -273,20 +273,20 @@ func (s *Service) UploadNDA(
} }
var ( var (
compliancePage *coredata.CompliancePortal portal *coredata.CompliancePortal
file *coredata.File file *coredata.File
) )
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, conn pg.Tx) error { func(ctx context.Context, conn pg.Tx) error {
compliancePage = &coredata.CompliancePortal{} portal = &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, req.CompliancePortalID); err != nil { if err := portal.LoadByID(ctx, conn, scope, req.CompliancePortalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
if compliancePage.OrganizationID == gid.Nil { if portal.OrganizationID == gid.Nil {
return fmt.Errorf("compliance page %s has no organization", req.CompliancePortalID) return fmt.Errorf("compliance portal %s has no organization", req.CompliancePortalID)
} }
objectKey, err := uuid.NewV7() objectKey, err := uuid.NewV7()
@@ -304,7 +304,7 @@ func (s *Service) UploadNDA(
file = &coredata.File{ file = &coredata.File{
ID: fileID, ID: fileID,
OrganizationID: compliancePage.OrganizationID, OrganizationID: portal.OrganizationID,
BucketName: s.bucket, BucketName: s.bucket,
MimeType: mimeType, MimeType: mimeType,
FileName: req.FileName, FileName: req.FileName,
@@ -321,7 +321,7 @@ func (s *Service) UploadNDA(
map[string]string{ map[string]string{
"type": "compliance-page-nda", "type": "compliance-page-nda",
"compliance-page-id": req.CompliancePortalID.String(), "compliance-page-id": req.CompliancePortalID.String(),
"organization-id": compliancePage.OrganizationID.String(), "organization-id": portal.OrganizationID.String(),
}, },
) )
if err != nil { if err != nil {
@@ -334,11 +334,11 @@ func (s *Service) UploadNDA(
return fmt.Errorf("cannot insert file: %w", err) return fmt.Errorf("cannot insert file: %w", err)
} }
compliancePage.NonDisclosureAgreementFileID = &fileID portal.NonDisclosureAgreementFileID = &fileID
compliancePage.UpdatedAt = now portal.UpdatedAt = now
if err := compliancePage.Update(ctx, conn, scope); err != nil { if err := portal.Update(ctx, conn, scope); err != nil {
return fmt.Errorf("cannot update compliance page: %w", err) return fmt.Errorf("cannot update compliance portal: %w", err)
} }
return nil return nil
@@ -348,29 +348,29 @@ func (s *Service) UploadNDA(
return nil, nil, err return nil, nil, err
} }
return compliancePage, file, nil return portal, file, nil
} }
func (s *Service) DeleteNDA( func (s *Service) DeleteNDA(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, portalID gid.GID,
) (*coredata.CompliancePortal, *coredata.File, error) { ) (*coredata.CompliancePortal, *coredata.File, error) {
var compliancePage *coredata.CompliancePortal var portal *coredata.CompliancePortal
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, conn pg.Tx) error { func(ctx context.Context, conn pg.Tx) error {
compliancePage = &coredata.CompliancePortal{} portal = &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := portal.LoadByID(ctx, conn, scope, portalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
compliancePage.NonDisclosureAgreementFileID = nil portal.NonDisclosureAgreementFileID = nil
compliancePage.UpdatedAt = time.Now() portal.UpdatedAt = time.Now()
if err := compliancePage.Update(ctx, conn, scope); err != nil { if err := portal.Update(ctx, conn, scope); err != nil {
return fmt.Errorf("cannot update compliance page: %w", err) return fmt.Errorf("cannot update compliance portal: %w", err)
} }
return nil return nil
@@ -380,7 +380,7 @@ func (s *Service) DeleteNDA(
return nil, nil, err return nil, nil, err
} }
return compliancePage, nil, nil return portal, nil, nil
} }
func (s *Service) UpdateBrand( func (s *Service) UpdateBrand(
@@ -393,55 +393,55 @@ func (s *Service) UpdateBrand(
} }
var ( var (
compliancePage *coredata.CompliancePortal portal *coredata.CompliancePortal
ndaFile *coredata.File ndaFile *coredata.File
) )
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, conn pg.Tx) error { func(ctx context.Context, conn pg.Tx) error {
compliancePage = &coredata.CompliancePortal{} portal = &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, req.CompliancePortalID); err != nil { if err := portal.LoadByID(ctx, conn, scope, req.CompliancePortalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
now := time.Now() now := time.Now()
if req.LogoFile != nil { if req.LogoFile != nil {
if *req.LogoFile == nil { if *req.LogoFile == nil {
compliancePage.LogoFileID = nil portal.LogoFileID = nil
} else { } else {
file, err := s.uploadBrandFile(ctx, scope, conn, *req.LogoFile, "compliance-page-logo", compliancePage) file, err := s.uploadBrandFile(ctx, scope, conn, *req.LogoFile, "compliance-page-logo", portal)
if err != nil { if err != nil {
return fmt.Errorf("cannot upload logo file: %w", err) return fmt.Errorf("cannot upload logo file: %w", err)
} }
compliancePage.LogoFileID = &file.ID portal.LogoFileID = &file.ID
} }
} }
if req.DarkLogoFile != nil { if req.DarkLogoFile != nil {
if *req.DarkLogoFile == nil { if *req.DarkLogoFile == nil {
compliancePage.DarkLogoFileID = nil portal.DarkLogoFileID = nil
} else { } else {
file, err := s.uploadBrandFile(ctx, scope, conn, *req.DarkLogoFile, "compliance-page-dark-logo", compliancePage) file, err := s.uploadBrandFile(ctx, scope, conn, *req.DarkLogoFile, "compliance-page-dark-logo", portal)
if err != nil { if err != nil {
return fmt.Errorf("cannot upload dark logo file: %w", err) return fmt.Errorf("cannot upload dark logo file: %w", err)
} }
compliancePage.DarkLogoFileID = &file.ID portal.DarkLogoFileID = &file.ID
} }
} }
compliancePage.UpdatedAt = now portal.UpdatedAt = now
if err := compliancePage.Update(ctx, conn, scope); err != nil { if err := portal.Update(ctx, conn, scope); err != nil {
return fmt.Errorf("cannot update compliance page: %w", err) return fmt.Errorf("cannot update compliance portal: %w", err)
} }
if compliancePage.NonDisclosureAgreementFileID != nil { if portal.NonDisclosureAgreementFileID != nil {
ndaFile = &coredata.File{} ndaFile = &coredata.File{}
if err := ndaFile.LoadByID(ctx, conn, scope, *compliancePage.NonDisclosureAgreementFileID); err != nil { if err := ndaFile.LoadByID(ctx, conn, scope, *portal.NonDisclosureAgreementFileID); err != nil {
return fmt.Errorf("cannot load nda file: %w", err) return fmt.Errorf("cannot load nda file: %w", err)
} }
} }
@@ -453,7 +453,7 @@ func (s *Service) UpdateBrand(
return nil, nil, err return nil, nil, err
} }
return compliancePage, ndaFile, nil return portal, ndaFile, nil
} }
func (s *Service) uploadBrandFile( func (s *Service) uploadBrandFile(
@@ -462,7 +462,7 @@ func (s *Service) uploadBrandFile(
conn pg.Tx, conn pg.Tx,
fileUpload *FileUpload, fileUpload *FileUpload,
fileType string, fileType string,
compliancePage *coredata.CompliancePortal, portal *coredata.CompliancePortal,
) (*coredata.File, error) { ) (*coredata.File, error) {
objectKey, err := uuid.NewV7() objectKey, err := uuid.NewV7()
if err != nil { if err != nil {
@@ -482,8 +482,8 @@ func (s *Service) uploadBrandFile(
CacheControl: new("max-age=3600, public"), CacheControl: new("max-age=3600, public"),
Metadata: map[string]string{ Metadata: map[string]string{
"type": fileType, "type": fileType,
"compliance-page-id": compliancePage.ID.String(), "compliance-page-id": portal.ID.String(),
"organization-id": compliancePage.OrganizationID.String(), "organization-id": portal.OrganizationID.String(),
}, },
}) })
if err != nil { if err != nil {
@@ -503,7 +503,7 @@ func (s *Service) uploadBrandFile(
file := &coredata.File{ file := &coredata.File{
ID: fileID, ID: fileID,
OrganizationID: compliancePage.OrganizationID, OrganizationID: portal.OrganizationID,
BucketName: s.bucket, BucketName: s.bucket,
MimeType: mimeType, MimeType: mimeType,
FileName: fileUpload.Filename, FileName: fileUpload.Filename,
@@ -524,26 +524,26 @@ func (s *Service) uploadBrandFile(
func (s *Service) GenerateNDAFileURL( func (s *Service) GenerateNDAFileURL(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, portalID gid.GID,
expiresIn time.Duration, expiresIn time.Duration,
) (*string, error) { ) (*string, error) {
var file *coredata.File var file *coredata.File
compliancePage := &coredata.CompliancePortal{} portal := &coredata.CompliancePortal{}
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := portal.LoadByID(ctx, conn, scope, portalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
if compliancePage.NonDisclosureAgreementFileID == nil { if portal.NonDisclosureAgreementFileID == nil {
return nil return nil
} }
file = &coredata.File{} file = &coredata.File{}
if err := file.LoadByID(ctx, conn, scope, *compliancePage.NonDisclosureAgreementFileID); err != nil { if err := file.LoadByID(ctx, conn, scope, *portal.NonDisclosureAgreementFileID); err != nil {
return fmt.Errorf("cannot load file: %w", err) return fmt.Errorf("cannot load file: %w", err)
} }
@@ -554,7 +554,7 @@ func (s *Service) GenerateNDAFileURL(
return nil, err return nil, err
} }
if compliancePage.NonDisclosureAgreementFileID == nil { if portal.NonDisclosureAgreementFileID == nil {
return nil, nil return nil, nil
} }
@@ -569,24 +569,24 @@ func (s *Service) GenerateNDAFileURL(
func (s *Service) GenerateLogoURL( func (s *Service) GenerateLogoURL(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, portalID gid.GID,
expiresIn time.Duration, expiresIn time.Duration,
) (*string, error) { ) (*string, error) {
file := &coredata.File{} file := &coredata.File{}
compliancePage := &coredata.CompliancePortal{} portal := &coredata.CompliancePortal{}
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := portal.LoadByID(ctx, conn, scope, portalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
if compliancePage.LogoFileID == nil { if portal.LogoFileID == nil {
return nil return nil
} }
if err := file.LoadByID(ctx, conn, scope, *compliancePage.LogoFileID); err != nil { if err := file.LoadByID(ctx, conn, scope, *portal.LogoFileID); err != nil {
return fmt.Errorf("cannot load file: %w", err) return fmt.Errorf("cannot load file: %w", err)
} }
@@ -597,7 +597,7 @@ func (s *Service) GenerateLogoURL(
return nil, err return nil, err
} }
if compliancePage.LogoFileID == nil { if portal.LogoFileID == nil {
return nil, nil return nil, nil
} }
@@ -616,24 +616,24 @@ func (s *Service) GenerateLogoURL(
func (s *Service) GenerateDarkLogoURL( func (s *Service) GenerateDarkLogoURL(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, portalID gid.GID,
expiresIn time.Duration, expiresIn time.Duration,
) (*string, error) { ) (*string, error) {
file := &coredata.File{} file := &coredata.File{}
compliancePage := &coredata.CompliancePortal{} portal := &coredata.CompliancePortal{}
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := portal.LoadByID(ctx, conn, scope, portalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
if compliancePage.DarkLogoFileID == nil { if portal.DarkLogoFileID == nil {
return nil return nil
} }
if err := file.LoadByID(ctx, conn, scope, *compliancePage.DarkLogoFileID); err != nil { if err := file.LoadByID(ctx, conn, scope, *portal.DarkLogoFileID); err != nil {
return fmt.Errorf("cannot load file: %w", err) return fmt.Errorf("cannot load file: %w", err)
} }
@@ -644,7 +644,7 @@ func (s *Service) GenerateDarkLogoURL(
return nil, err return nil, err
} }
if compliancePage.DarkLogoFileID == nil { if portal.DarkLogoFileID == nil {
return nil, nil return nil, nil
} }
@@ -663,39 +663,39 @@ func (s *Service) GenerateDarkLogoURL(
func (s *Service) EmailPresenterConfig( func (s *Service) EmailPresenterConfig(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, portalID gid.GID,
) (emails.PresenterConfig, error) { ) (emails.PresenterConfig, error) {
var ( var (
compliancePage = &coredata.CompliancePortal{} portal = &coredata.CompliancePortal{}
organization = &coredata.Organization{} organization = &coredata.Organization{}
logoFile = &coredata.File{} logoFile = &coredata.File{}
compliancePageURL string portalURL string
emailPresenterCfg = emails.DefaultPresenterConfig(s.baseURL) emailPresenterCfg = emails.DefaultPresenterConfig(s.baseURL)
) )
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := portal.LoadByID(ctx, conn, scope, portalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
if compliancePage.LogoFileID != nil { if portal.LogoFileID != nil {
if err := logoFile.LoadByID(ctx, conn, scope, *compliancePage.LogoFileID); err != nil { if err := logoFile.LoadByID(ctx, conn, scope, *portal.LogoFileID); err != nil {
return fmt.Errorf("cannot load logoFile: %w", err) return fmt.Errorf("cannot load logoFile: %w", err)
} }
} }
if err := organization.LoadByID(ctx, conn, scope, compliancePage.OrganizationID); err != nil { if err := organization.LoadByID(ctx, conn, scope, portal.OrganizationID); err != nil {
return fmt.Errorf("cannot load organization: %w", err) return fmt.Errorf("cannot load organization: %w", err)
} }
publicURL, err := s.PublicURLForCompliancePortal(ctx, conn, scope, compliancePage) publicURL, err := s.PublicURLForCompliancePortal(ctx, conn, scope, portal)
if err != nil { if err != nil {
return fmt.Errorf("cannot resolve compliance page URL: %w", err) return fmt.Errorf("cannot resolve compliance portal URL: %w", err)
} }
compliancePageURL = publicURL portalURL = publicURL
return nil return nil
}, },
@@ -704,9 +704,9 @@ func (s *Service) EmailPresenterConfig(
return emailPresenterCfg, err return emailPresenterCfg, err
} }
emailPresenterCfg.BaseURL = compliancePageURL emailPresenterCfg.BaseURL = portalURL
if compliancePage.LogoFileID != nil { if portal.LogoFileID != nil {
if logoFile.FileKey == "" { if logoFile.FileKey == "" {
return emailPresenterCfg, nil return emailPresenterCfg, nil
} }
@@ -714,12 +714,12 @@ func (s *Service) EmailPresenterConfig(
emailPresenterCfg.SenderCompanyLogoPath = filepath.Join("/api/files/v1/public/", logoFile.ID.String()) emailPresenterCfg.SenderCompanyLogoPath = filepath.Join("/api/files/v1/public/", logoFile.ID.String())
emailPresenterCfg.SenderCompanyName = organization.Name emailPresenterCfg.SenderCompanyName = organization.Name
if compliancePage.WebsiteURL != nil { if portal.WebsiteURL != nil {
emailPresenterCfg.SenderCompanyWebsiteURL = *compliancePage.WebsiteURL emailPresenterCfg.SenderCompanyWebsiteURL = *portal.WebsiteURL
} }
if compliancePage.HeadquarterAddress != nil { if portal.HeadquarterAddress != nil {
emailPresenterCfg.SenderCompanyHeadquarterAddress = *compliancePage.HeadquarterAddress emailPresenterCfg.SenderCompanyHeadquarterAddress = *portal.HeadquarterAddress
} }
} }
@@ -729,24 +729,24 @@ func (s *Service) EmailPresenterConfig(
func (s *Service) GetMailingList( func (s *Service) GetMailingList(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, portalID gid.GID,
) (*coredata.MailingList, error) { ) (*coredata.MailingList, error) {
var mailingList *coredata.MailingList var mailingList *coredata.MailingList
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
compliancePage := &coredata.CompliancePortal{} portal := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := portal.LoadByID(ctx, conn, scope, portalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
if compliancePage.MailingListID == nil { if portal.MailingListID == nil {
return nil return nil
} }
mailingList = &coredata.MailingList{} mailingList = &coredata.MailingList{}
if err := mailingList.LoadByID(ctx, conn, scope, *compliancePage.MailingListID); err != nil { if err := mailingList.LoadByID(ctx, conn, scope, *portal.MailingListID); err != nil {
return fmt.Errorf("cannot load mailing list: %w", err) return fmt.Errorf("cannot load mailing list: %w", err)
} }