Rename backend services for portal

Point domain services, bootstrap, and related
packages at Compliance Portal types so callers
stop depending on the old Trust Center names.

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-07-20 18:08:21 +02:00
parent 4bf3d4df79
commit 0f0f6643ad
47 changed files with 727 additions and 727 deletions

View File

@@ -89,7 +89,7 @@ func (s *Service) ListAuditsForOrganizationID(
var audits coredata.Audits
if filter == nil {
filter = coredata.NewAuditTrustCenterFilter()
filter = coredata.NewAuditCompliancePortalFilter()
}
err := s.pg.WithConn(

View File

@@ -65,7 +65,7 @@ func PortalBaseURLFromCIMDClientID(clientIDURL string) (string, error) {
}
func BuildClientMetadataDocument(
portal *coredata.TrustCenter,
portal *coredata.CompliancePortal,
portalBaseURL string,
) (oauth2.ClientMetadataDocument, error) {
clientID, err := CIMDClientIDURL(portalBaseURL)

View File

@@ -65,7 +65,7 @@ func TestBuildClientMetadataDocument(t *testing.T) {
t.Parallel()
websiteURL := "https://www.acme.com"
portal := &coredata.TrustCenter{
portal := &coredata.CompliancePortal{
Title: "Acme Compliance Page",
WebsiteURL: &websiteURL,
}
@@ -87,7 +87,7 @@ func TestBuildClientMetadataDocument_LogoURIUsesBrandLogoEndpoint(t *testing.T)
t.Parallel()
logoFileID := gid.MustParseGID("WR-qMrB5AAEAGQAAAZ9mIO8B8vDFQ-i3")
portal := &coredata.TrustCenter{
portal := &coredata.CompliancePortal{
Title: "Acme Compliance Page",
LogoFileID: &logoFileID,
}

View File

@@ -66,7 +66,7 @@ func (s *Service) ListComplianceFrameworksByPortalID(
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
err := complianceFrameworks.LoadByTrustCenterID(ctx, conn, scope, compliancePageID, cursor)
err := complianceFrameworks.LoadByCompliancePortalID(ctx, conn, scope, compliancePageID, cursor)
if err != nil {
return fmt.Errorf("cannot load compliance frameworks: %w", err)
}

View File

@@ -33,7 +33,7 @@ import (
func (s *Service) ListCommitmentGroupsForPortalID(
ctx context.Context,
scope coredata.Scoper,
trustCenterID gid.GID,
compliancePortalID gid.GID,
cursor *page.Cursor[coredata.CompliancePortalCommitmentGroupOrderField],
) (*page.Page[*coredata.CompliancePortalCommitmentGroup, coredata.CompliancePortalCommitmentGroupOrderField], error) {
var groups coredata.CompliancePortalCommitmentGroups
@@ -41,7 +41,7 @@ func (s *Service) ListCommitmentGroupsForPortalID(
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
err := groups.LoadByTrustCenterID(ctx, conn, scope, trustCenterID, cursor)
err := groups.LoadByCompliancePortalID(ctx, conn, scope, compliancePortalID, cursor)
if err != nil {
return fmt.Errorf("cannot load compliance portal commitment groups: %w", err)
}

View File

@@ -119,7 +119,7 @@ type (
}
)
func (s *Service) RenderCompliancePageMarkdown(
func (s *Service) RenderCompliancePortalMarkdown(
ctx context.Context,
w io.Writer,
compliancePageID gid.GID,
@@ -286,7 +286,7 @@ func (s *Service) fetchDocumentIDs(
}
for _, doc := range result.Data {
if doc.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
if doc.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
continue
}
@@ -308,8 +308,8 @@ func (s *Service) fetchDocumentIDs(
page.MaxCursorSize,
cursorKey,
page.Head,
page.OrderBy[coredata.TrustCenterFileOrderField]{
Field: coredata.TrustCenterFileOrderFieldCreatedAt,
page.OrderBy[coredata.CompliancePortalFileOrderField]{
Field: coredata.CompliancePortalFileOrderFieldCreatedAt,
Direction: page.OrderDirectionAsc,
},
)
@@ -319,14 +319,14 @@ func (s *Service) fetchDocumentIDs(
scope,
orgID,
cursor,
coredata.NewTrustCenterFileFilter(),
coredata.NewCompliancePortalFileFilter(),
)
if err != nil {
return nil, fmt.Errorf("cannot list compliance page files: %w", err)
}
for _, file := range result.Data {
if file.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
if file.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
continue
}
@@ -338,7 +338,7 @@ func (s *Service) fetchDocumentIDs(
}
last := result.Data[len(result.Data)-1]
ck := last.CursorKey(coredata.TrustCenterFileOrderFieldCreatedAt)
ck := last.CursorKey(coredata.CompliancePortalFileOrderFieldCreatedAt)
cursorKey = &ck
}
@@ -360,7 +360,7 @@ func (s *Service) fetchDocumentIDs(
}
for _, audit := range result.Data {
if audit.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
if audit.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
continue
}
@@ -477,7 +477,7 @@ func (s *Service) fetchDocuments(
}
for _, doc := range result.Data {
if doc.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
if doc.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
continue
}
@@ -527,7 +527,7 @@ func (s *Service) fetchAudits(
}
for _, audit := range result.Data {
if audit.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
if audit.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
continue
}
@@ -631,8 +631,8 @@ func (s *Service) fetchReferences(
page.MaxCursorSize,
cursorKey,
page.Head,
page.OrderBy[coredata.TrustCenterReferenceOrderField]{
Field: coredata.TrustCenterReferenceOrderFieldRank,
page.OrderBy[coredata.CompliancePortalReferenceOrderField]{
Field: coredata.CompliancePortalReferenceOrderFieldRank,
Direction: page.OrderDirectionAsc,
},
)
@@ -659,7 +659,7 @@ func (s *Service) fetchReferences(
}
last := result.Data[len(result.Data)-1]
ck := last.CursorKey(coredata.TrustCenterReferenceOrderFieldRank)
ck := last.CursorKey(coredata.CompliancePortalReferenceOrderFieldRank)
cursorKey = &ck
}

View File

@@ -41,7 +41,7 @@ func (s *Service) ListCustomLinksForPortalID(
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
err := links.LoadByTrustCenterID(ctx, conn, scope, compliancePageID, cursor)
err := links.LoadByCompliancePortalID(ctx, conn, scope, compliancePageID, cursor)
if err != nil {
return fmt.Errorf("cannot load custom links: %w", err)
}

View File

@@ -53,7 +53,7 @@ func (s *Service) ListDocumentsForOrganizationID(
var documents coredata.Documents
if filter == nil {
filter = coredata.NewDocumentTrustCenterFilter()
filter = coredata.NewDocumentCompliancePortalFilter()
}
err := s.pg.WithConn(
@@ -131,7 +131,7 @@ func (s *Service) GetDocument(
return nil, ErrDocumentNotFound
}
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
if document.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
return nil, ErrDocumentNotVisible
}
@@ -158,7 +158,7 @@ func (s *Service) exportDocumentPDFData(
return &ErrDocumentArchived{}
}
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
if document.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
return fmt.Errorf("document not visible on compliance page")
}

View File

@@ -36,37 +36,37 @@ import (
)
type PortalAccessRequest struct {
TrustCenterID gid.GID
IdentityID gid.GID
DocumentIDs []gid.GID
ReportIDs []gid.GID
TrustCenterFileIDs []gid.GID
CompliancePortalID gid.GID
IdentityID gid.GID
DocumentIDs []gid.GID
ReportIDs []gid.GID
CompliancePortalFileIDs []gid.GID
}
const (
PortalAccessURLFormat = "https://%s/organizations/%s/trust-center/access"
PortalAccessURLFormat = "https://%s/organizations/%s/compliance-page/access"
)
func (s *Service) RequestPortalAccess(
ctx context.Context,
scope coredata.Scoper,
req *PortalAccessRequest,
) (*coredata.TrustCenterAccess, error) {
) (*coredata.CompliancePortalAccess, error) {
var (
now = time.Now()
access *coredata.TrustCenterAccess
access *coredata.CompliancePortalAccess
)
err := s.pg.WithTx(
ctx,
func(ctx context.Context, tx pg.Tx) error {
compliancePage := &coredata.TrustCenter{}
if err := compliancePage.LoadByID(ctx, tx, scope, req.TrustCenterID); err != nil {
compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, tx, scope, req.CompliancePortalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err)
}
access = &coredata.TrustCenterAccess{}
if err := access.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, req.TrustCenterID, req.IdentityID); err != nil {
access = &coredata.CompliancePortalAccess{}
if err := access.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, req.CompliancePortalID, req.IdentityID); err != nil {
return fmt.Errorf("cannot load compliance page membership: %w", err)
}
@@ -74,7 +74,7 @@ func (s *Service) RequestPortalAccess(
documentIDs := req.DocumentIDs
if req.DocumentIDs == nil {
filter := coredata.NewDocumentTrustCenterFilter()
filter := coredata.NewDocumentCompliancePortalFilter()
allDocuments, err := page.LoadAll(
ctx,
@@ -102,7 +102,7 @@ func (s *Service) RequestPortalAccess(
reportIDs := req.ReportIDs
if req.ReportIDs == nil {
auditFilter := coredata.NewAuditTrustCenterFilter()
auditFilter := coredata.NewAuditCompliancePortalFilter()
allAudits, err := page.LoadAll(
ctx,
@@ -130,20 +130,20 @@ func (s *Service) RequestPortalAccess(
}
}
trustCenterFileIDs := req.TrustCenterFileIDs
if req.TrustCenterFileIDs == nil {
filter := coredata.NewTrustCenterFileFilter(
coredata.WithTrustCenterFileVisibilities(coredata.TrustCenterVisibilityPrivate, coredata.TrustCenterVisibilityNone),
compliancePortalFileIDs := req.CompliancePortalFileIDs
if req.CompliancePortalFileIDs == nil {
filter := coredata.NewCompliancePortalFileFilter(
coredata.WithCompliancePortalFileVisibilities(coredata.CompliancePortalVisibilityPrivate, coredata.CompliancePortalVisibilityNone),
)
allTrustCenterFiles, err := page.LoadAll(
allCompliancePortalFiles, err := page.LoadAll(
ctx,
page.OrderBy[coredata.TrustCenterFileOrderField]{
Field: coredata.TrustCenterFileOrderFieldCreatedAt,
page.OrderBy[coredata.CompliancePortalFileOrderField]{
Field: coredata.CompliancePortalFileOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc,
},
func(ctx context.Context, cursor *page.Cursor[coredata.TrustCenterFileOrderField]) ([]*coredata.TrustCenterFile, error) {
var batch coredata.TrustCenterFiles
func(ctx context.Context, cursor *page.Cursor[coredata.CompliancePortalFileOrderField]) ([]*coredata.CompliancePortalFile, error) {
var batch coredata.CompliancePortalFiles
if err := batch.LoadByOrganizationID(ctx, tx, scope, organizationID, cursor, filter); err != nil {
return nil, fmt.Errorf("cannot list compliance page files: %w", err)
}
@@ -155,20 +155,20 @@ func (s *Service) RequestPortalAccess(
return err
}
for _, file := range allTrustCenterFiles {
trustCenterFileIDs = append(trustCenterFileIDs, file.ID)
for _, file := range allCompliancePortalFiles {
compliancePortalFileIDs = append(compliancePortalFileIDs, file.ID)
}
}
existingAccesses, err := page.LoadAll(
ctx,
page.OrderBy[coredata.TrustCenterDocumentAccessOrderField]{
Field: coredata.TrustCenterDocumentAccessOrderFieldCreatedAt,
page.OrderBy[coredata.CompliancePortalDocumentAccessOrderField]{
Field: coredata.CompliancePortalDocumentAccessOrderFieldCreatedAt,
Direction: page.OrderDirectionAsc,
},
func(ctx context.Context, cursor *page.Cursor[coredata.TrustCenterDocumentAccessOrderField]) ([]*coredata.TrustCenterDocumentAccess, error) {
var batch coredata.TrustCenterDocumentAccesses
if err := batch.LoadByTrustCenterAccessID(ctx, tx, scope, access.ID, cursor); err != nil {
func(ctx context.Context, cursor *page.Cursor[coredata.CompliancePortalDocumentAccessOrderField]) ([]*coredata.CompliancePortalDocumentAccess, error) {
var batch coredata.CompliancePortalDocumentAccesses
if err := batch.LoadByCompliancePortalAccessID(ctx, tx, scope, access.ID, cursor); err != nil {
return nil, fmt.Errorf("cannot load existing access records: %w", err)
}
@@ -179,12 +179,12 @@ func (s *Service) RequestPortalAccess(
return err
}
existingDocumentIDs, existingReportIDs, existingTrustCenterFileIDs := extractExistingIDs(existingAccesses)
existingDocumentIDs, existingReportIDs, existingCompliancePortalFileIDs := extractExistingIDs(existingAccesses)
newDocumentIDs := filterExistingIDs(documentIDs, existingDocumentIDs)
newReportIDs := filterExistingIDs(reportIDs, existingReportIDs)
newTrustCenterFileIDs := filterExistingIDs(trustCenterFileIDs, existingTrustCenterFileIDs)
newCompliancePortalFileIDs := filterExistingIDs(compliancePortalFileIDs, existingCompliancePortalFileIDs)
var accesses coredata.TrustCenterDocumentAccesses
var accesses coredata.CompliancePortalDocumentAccesses
if err := accesses.BulkInsertDocumentAccesses(
ctx,
@@ -193,7 +193,7 @@ func (s *Service) RequestPortalAccess(
access.ID,
access.OrganizationID,
newDocumentIDs,
coredata.TrustCenterDocumentAccessStatusRequested,
coredata.CompliancePortalDocumentAccessStatusRequested,
now,
); err != nil {
return fmt.Errorf("cannot bulk insert compliance page document accesses: %w", err)
@@ -206,20 +206,20 @@ func (s *Service) RequestPortalAccess(
access.ID,
access.OrganizationID,
newReportIDs,
coredata.TrustCenterDocumentAccessStatusRequested,
coredata.CompliancePortalDocumentAccessStatusRequested,
now,
); err != nil {
return fmt.Errorf("cannot bulk insert compliance page report accesses: %w", err)
}
if err := accesses.BulkInsertTrustCenterFileAccesses(
if err := accesses.BulkInsertCompliancePortalFileAccesses(
ctx,
tx,
scope,
access.ID,
access.OrganizationID,
newTrustCenterFileIDs,
coredata.TrustCenterDocumentAccessStatusRequested,
newCompliancePortalFileIDs,
coredata.CompliancePortalDocumentAccessStatusRequested,
now,
); err != nil {
return fmt.Errorf("cannot bulk insert compliance page file accesses: %w", err)
@@ -232,7 +232,7 @@ func (s *Service) RequestPortalAccess(
return nil, err
}
if err := s.slack.QueueSlackNotification(ctx, scope, req.IdentityID, req.TrustCenterID); err != nil {
if err := s.slack.QueueSlackNotification(ctx, scope, req.IdentityID, req.CompliancePortalID); err != nil {
s.logger.ErrorCtx(ctx, "cannot queue slack notification", log.Error(err))
}
@@ -244,13 +244,13 @@ func (s *Service) GetPortalAccess(
scope coredata.Scoper,
compliancePageID gid.GID,
identityID gid.GID,
) (coredata.TrustCenterAccess, error) {
var access coredata.TrustCenterAccess
) (coredata.CompliancePortalAccess, error) {
var access coredata.CompliancePortalAccess
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
return access.LoadByTrustCenterIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID)
return access.LoadByCompliancePortalIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID)
},
)
@@ -263,15 +263,15 @@ func (s *Service) GetPortalDocumentAccess(
compliancePageID gid.GID,
identityID gid.GID,
documentID gid.GID,
) (*coredata.TrustCenterDocumentAccess, error) {
var documentAccess *coredata.TrustCenterDocumentAccess
) (*coredata.CompliancePortalDocumentAccess, error) {
var documentAccess *coredata.CompliancePortalDocumentAccess
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
access := &coredata.TrustCenterAccess{}
access := &coredata.CompliancePortalAccess{}
err := access.LoadByTrustCenterIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID)
err := access.LoadByCompliancePortalIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrMembershipNotFound
@@ -291,9 +291,9 @@ func (s *Service) GetPortalDocumentAccess(
return ErrUserInactive
}
documentAccess = &coredata.TrustCenterDocumentAccess{}
documentAccess = &coredata.CompliancePortalDocumentAccess{}
err = documentAccess.LoadByTrustCenterAccessIDAndDocumentID(ctx, conn, scope, access.ID, documentID)
err = documentAccess.LoadByCompliancePortalAccessIDAndDocumentID(ctx, conn, scope, access.ID, documentID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrDocumentAccessNotFound
@@ -318,15 +318,15 @@ func (s *Service) GetPortalReportFileAccess(
compliancePageID gid.GID,
identityID gid.GID,
reportFileID gid.GID,
) (*coredata.TrustCenterDocumentAccess, error) {
var reportAccess *coredata.TrustCenterDocumentAccess
) (*coredata.CompliancePortalDocumentAccess, error) {
var reportAccess *coredata.CompliancePortalDocumentAccess
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
access := &coredata.TrustCenterAccess{}
access := &coredata.CompliancePortalAccess{}
err := access.LoadByTrustCenterIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID)
err := access.LoadByCompliancePortalIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrMembershipNotFound
@@ -346,9 +346,9 @@ func (s *Service) GetPortalReportFileAccess(
return ErrUserInactive
}
reportAccess = &coredata.TrustCenterDocumentAccess{}
reportAccess = &coredata.CompliancePortalDocumentAccess{}
err = reportAccess.LoadByTrustCenterAccessIDAndReportFileID(ctx, conn, scope, access.ID, reportFileID)
err = reportAccess.LoadByCompliancePortalAccessIDAndReportFileID(ctx, conn, scope, access.ID, reportFileID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrDocumentAccessNotFound
@@ -372,16 +372,16 @@ func (s *Service) GetPortalFileAccess(
scope coredata.Scoper,
compliancePageID gid.GID,
identityID gid.GID,
trustCenterFileID gid.GID,
) (*coredata.TrustCenterDocumentAccess, error) {
var fileAccess *coredata.TrustCenterDocumentAccess
compliancePortalFileID gid.GID,
) (*coredata.CompliancePortalDocumentAccess, error) {
var fileAccess *coredata.CompliancePortalDocumentAccess
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
access := &coredata.TrustCenterAccess{}
access := &coredata.CompliancePortalAccess{}
err := access.LoadByTrustCenterIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID)
err := access.LoadByCompliancePortalIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrMembershipNotFound
@@ -401,9 +401,9 @@ func (s *Service) GetPortalFileAccess(
return ErrUserInactive
}
fileAccess = &coredata.TrustCenterDocumentAccess{}
fileAccess = &coredata.CompliancePortalDocumentAccess{}
err = fileAccess.LoadByTrustCenterAccessIDAndTrustCenterFileID(ctx, conn, scope, access.ID, trustCenterFileID)
err = fileAccess.LoadByCompliancePortalAccessIDAndCompliancePortalFileID(ctx, conn, scope, access.ID, compliancePortalFileID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrDocumentAccessNotFound
@@ -434,7 +434,7 @@ func (s *Service) GrantPortalAccessByIDs(
return s.pg.WithTx(
ctx,
func(ctx context.Context, tx pg.Tx) error {
compliancePage := &coredata.TrustCenter{}
compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByOrganizationID(ctx, tx, scope, organizationID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err)
}
@@ -444,8 +444,8 @@ func (s *Service) GrantPortalAccessByIDs(
return fmt.Errorf("cannot load identity: %w", err)
}
access := &coredata.TrustCenterAccess{}
if err := access.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, compliancePage.ID, identity.ID); err != nil {
access := &coredata.CompliancePortalAccess{}
if err := access.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, compliancePage.ID, identity.ID); err != nil {
return fmt.Errorf("cannot load compliance page access: %w", err)
}
@@ -476,7 +476,7 @@ func (s *Service) GrantPortalAccessByIDs(
}
if len(fileIDs) > 0 {
if err := coredata.GrantByTrustCenterFileIDs(ctx, tx, scope, access.ID, fileIDs, now); err != nil {
if err := coredata.GrantByCompliancePortalFileIDs(ctx, tx, scope, access.ID, fileIDs, now); err != nil {
return fmt.Errorf("cannot grant compliance page file accesses: %w", err)
}
}
@@ -503,7 +503,7 @@ func (s *Service) sendPortalAccessEmail(
ctx context.Context,
tx pg.Tx,
scope coredata.Scoper,
access *coredata.TrustCenterAccess,
access *coredata.CompliancePortalAccess,
profile *coredata.MembershipProfile,
) error {
organization := &coredata.Organization{}
@@ -518,14 +518,14 @@ func (s *Service) sendPortalAccessEmail(
return fmt.Errorf("cannot update compliance page access with expiration: %w", err)
}
emailPresenterCfg, err := s.GetPortalEmailPresenterConfig(ctx, scope, access.TrustCenterID)
emailPresenterCfg, err := s.GetPortalEmailPresenterConfig(ctx, scope, access.CompliancePortalID)
if err != nil {
return fmt.Errorf("cannot get compliance page email presenter config: %w", err)
}
emailPresenter := emails.NewPresenterFromConfig(emailPresenterCfg, profile.FullName)
subject, textBody, htmlBody, err := emailPresenter.RenderTrustCenterAccess(ctx, organization.Name)
subject, textBody, htmlBody, err := emailPresenter.RenderCompliancePortalAccess(ctx, organization.Name)
if err != nil {
return fmt.Errorf("cannot render compliance page access email: %w", err)
}
@@ -560,7 +560,7 @@ func (s *Service) RejectOrRevokePortalAccessByIDs(
return s.pg.WithTx(
ctx,
func(ctx context.Context, tx pg.Tx) error {
compliancePage := &coredata.TrustCenter{}
compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByOrganizationID(ctx, tx, scope, organizationID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err)
}
@@ -570,8 +570,8 @@ func (s *Service) RejectOrRevokePortalAccessByIDs(
return fmt.Errorf("cannot load identity: %w", err)
}
access := &coredata.TrustCenterAccess{}
if err := access.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, compliancePage.ID, identity.ID); err != nil {
access := &coredata.CompliancePortalAccess{}
if err := access.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, compliancePage.ID, identity.ID); err != nil {
return fmt.Errorf("cannot load compliance page access: %w", err)
}
@@ -602,7 +602,7 @@ func (s *Service) RejectOrRevokePortalAccessByIDs(
if len(fileIDs) > 0 {
shouldSendEmail = true
if err := coredata.RejectOrRevokeByTrustCenterFileIDs(ctx, tx, scope, access.ID, fileIDs, now); err != nil {
if err := coredata.RejectOrRevokeByCompliancePortalFileIDs(ctx, tx, scope, access.ID, fileIDs, now); err != nil {
return fmt.Errorf("cannot reject/revoke compliance page file accesses: %w", err)
}
}
@@ -622,7 +622,7 @@ func (s *Service) sendPortalDocumentAccessRejectedEmail(
ctx context.Context,
tx pg.Tx,
scope coredata.Scoper,
access *coredata.TrustCenterAccess,
access *coredata.CompliancePortalAccess,
profile *coredata.MembershipProfile,
documentIDs []gid.GID,
reportIDs []gid.GID,
@@ -657,7 +657,7 @@ func (s *Service) sendPortalDocumentAccessRejectedEmail(
fileNames = append(fileNames, reportLabels...)
}
var files coredata.TrustCenterFiles
var files coredata.CompliancePortalFiles
if len(fileIDs) > 0 {
if err := files.LoadByIDs(ctx, tx, scope, fileIDs); err != nil && !errors.Is(err, coredata.ErrResourceNotFound) {
return fmt.Errorf("cannot load files by IDs: %w", err)
@@ -668,14 +668,14 @@ func (s *Service) sendPortalDocumentAccessRejectedEmail(
}
}
emailPresenterCfg, err := s.GetPortalEmailPresenterConfig(ctx, scope, access.TrustCenterID)
emailPresenterCfg, err := s.GetPortalEmailPresenterConfig(ctx, scope, access.CompliancePortalID)
if err != nil {
return fmt.Errorf("cannot get compliance page email presenter config: %w", err)
}
emailPresenter := emails.NewPresenterFromConfig(emailPresenterCfg, profile.FullName)
subject, textBody, htmlBody, err := emailPresenter.RenderTrustCenterDocumentAccessRejected(
subject, textBody, htmlBody, err := emailPresenter.RenderCompliancePortalDocumentAccessRejected(
ctx,
fileNames,
organization.Name,
@@ -702,11 +702,11 @@ func (s *Service) sendPortalDocumentAccessRejectedEmail(
return nil
}
func extractExistingIDs(accesses coredata.TrustCenterDocumentAccesses) ([]gid.GID, []gid.GID, []gid.GID) {
func extractExistingIDs(accesses coredata.CompliancePortalDocumentAccesses) ([]gid.GID, []gid.GID, []gid.GID) {
var (
documentIDs []gid.GID
reportIDs []gid.GID
trustCenterFileIDs []gid.GID
documentIDs []gid.GID
reportIDs []gid.GID
compliancePortalFileIDs []gid.GID
)
for _, access := range accesses {
@@ -718,12 +718,12 @@ func extractExistingIDs(accesses coredata.TrustCenterDocumentAccesses) ([]gid.GI
reportIDs = append(reportIDs, *access.ReportFileID)
}
if access.TrustCenterFileID != nil {
trustCenterFileIDs = append(trustCenterFileIDs, *access.TrustCenterFileID)
if access.CompliancePortalFileID != nil {
compliancePortalFileIDs = append(compliancePortalFileIDs, *access.CompliancePortalFileID)
}
}
return documentIDs, reportIDs, trustCenterFileIDs
return documentIDs, reportIDs, compliancePortalFileIDs
}
func filterExistingIDs(allIDs []gid.GID, existingIDs []gid.GID) []gid.GID {

View File

@@ -38,14 +38,14 @@ func (s *Service) GetPortalFile(
ctx context.Context,
scope coredata.Scoper,
organizationID gid.GID,
trustCenterFileID gid.GID,
) (*coredata.TrustCenterFile, error) {
trustCenterFile := &coredata.TrustCenterFile{}
compliancePortalFileID gid.GID,
) (*coredata.CompliancePortalFile, error) {
compliancePortalFile := &coredata.CompliancePortalFile{}
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
err := trustCenterFile.LoadByID(ctx, conn, scope, trustCenterFileID)
err := compliancePortalFile.LoadByID(ctx, conn, scope, compliancePortalFileID)
if err != nil {
return fmt.Errorf("cannot load compliance page file: %w", err)
}
@@ -57,30 +57,30 @@ func (s *Service) GetPortalFile(
return nil, err
}
if trustCenterFile.OrganizationID != organizationID {
if compliancePortalFile.OrganizationID != organizationID {
return nil, ErrPortalFileNotFound
}
if trustCenterFile.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
if compliancePortalFile.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
return nil, ErrPortalFileNotVisible
}
return trustCenterFile, nil
return compliancePortalFile, nil
}
func (s *Service) ListPortalFilesForOrganizationID(
ctx context.Context,
scope coredata.Scoper,
organizationID gid.GID,
cursor *page.Cursor[coredata.TrustCenterFileOrderField],
filter *coredata.TrustCenterFileFilter,
) (*page.Page[*coredata.TrustCenterFile, coredata.TrustCenterFileOrderField], error) {
var trustCenterFiles coredata.TrustCenterFiles
cursor *page.Cursor[coredata.CompliancePortalFileOrderField],
filter *coredata.CompliancePortalFileFilter,
) (*page.Page[*coredata.CompliancePortalFile, coredata.CompliancePortalFileOrderField], error) {
var compliancePortalFiles coredata.CompliancePortalFiles
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
err := trustCenterFiles.LoadByOrganizationID(ctx, conn, scope, organizationID, cursor, filter)
err := compliancePortalFiles.LoadByOrganizationID(ctx, conn, scope, organizationID, cursor, filter)
if err != nil {
return fmt.Errorf("cannot load compliance page files: %w", err)
}
@@ -92,16 +92,16 @@ func (s *Service) ListPortalFilesForOrganizationID(
return nil, err
}
return page.NewPage(trustCenterFiles, cursor), nil
return page.NewPage(compliancePortalFiles, cursor), nil
}
func (s *Service) ExportPortalFile(
ctx context.Context,
scope coredata.Scoper,
trustCenterFileID gid.GID,
compliancePortalFileID gid.GID,
email mail.Addr,
) ([]byte, string, error) {
fileData, mimeType, err := s.exportPortalFileData(ctx, scope, trustCenterFileID)
fileData, mimeType, err := s.exportPortalFileData(ctx, scope, compliancePortalFileID)
if err != nil {
return nil, "", fmt.Errorf("cannot export compliance page file: %w", err)
}
@@ -121,31 +121,31 @@ func (s *Service) ExportPortalFile(
func (s *Service) ExportPortalFileWithoutWatermark(
ctx context.Context,
scope coredata.Scoper,
trustCenterFileID gid.GID,
compliancePortalFileID gid.GID,
) ([]byte, string, error) {
return s.exportPortalFileData(ctx, scope, trustCenterFileID)
return s.exportPortalFileData(ctx, scope, compliancePortalFileID)
}
func (s *Service) exportPortalFileData(
ctx context.Context,
scope coredata.Scoper,
trustCenterFileID gid.GID,
compliancePortalFileID gid.GID,
) ([]byte, string, error) {
var (
trustCenterFile *coredata.TrustCenterFile
file *coredata.File
compliancePortalFile *coredata.CompliancePortalFile
file *coredata.File
)
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
trustCenterFile = &coredata.TrustCenterFile{}
if err := trustCenterFile.LoadByID(ctx, conn, scope, trustCenterFileID); err != nil {
compliancePortalFile = &coredata.CompliancePortalFile{}
if err := compliancePortalFile.LoadByID(ctx, conn, scope, compliancePortalFileID); err != nil {
return fmt.Errorf("cannot load compliance page file: %w", err)
}
file = &coredata.File{}
if err := file.LoadByID(ctx, conn, scope, trustCenterFile.FileID); err != nil {
if err := file.LoadByID(ctx, conn, scope, compliancePortalFile.FileID); err != nil {
return fmt.Errorf("cannot load file: %w", err)
}

View File

@@ -34,16 +34,16 @@ func (s *Service) ListPortalReferencesForPortalID(
ctx context.Context,
scope coredata.Scoper,
compliancePageID gid.GID,
cursor *page.Cursor[coredata.TrustCenterReferenceOrderField],
) (*page.Page[*coredata.TrustCenterReference, coredata.TrustCenterReferenceOrderField], error) {
var references coredata.TrustCenterReferences
cursor *page.Cursor[coredata.CompliancePortalReferenceOrderField],
) (*page.Page[*coredata.CompliancePortalReference, coredata.CompliancePortalReferenceOrderField], error) {
var references coredata.CompliancePortalReferences
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
err := references.LoadByTrustCenterID(ctx, conn, scope, compliancePageID, cursor)
err := references.LoadByCompliancePortalID(ctx, conn, scope, compliancePageID, cursor)
if err != nil {
return fmt.Errorf("cannot load compliance page references: %w", err)
}
@@ -62,8 +62,8 @@ func (s *Service) GetPortalReference(
ctx context.Context,
scope coredata.Scoper,
referenceID gid.GID,
) (*coredata.TrustCenterReference, error) {
reference := &coredata.TrustCenterReference{}
) (*coredata.CompliancePortalReference, error) {
reference := &coredata.CompliancePortalReference{}
err := s.pg.WithConn(
ctx,

View File

@@ -36,13 +36,13 @@ func (s *Service) GetPortal(
ctx context.Context,
scope coredata.Scoper,
compliancePageID gid.GID,
) (*coredata.TrustCenter, error) {
var compliancePage *coredata.TrustCenter
) (*coredata.CompliancePortal, error) {
var compliancePage *coredata.CompliancePortal
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
compliancePage = &coredata.TrustCenter{}
compliancePage = &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err)
}
@@ -67,7 +67,7 @@ func (s *Service) GetPortalNDAFile(
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
compliancePage := &coredata.TrustCenter{}
compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err)
}
@@ -102,7 +102,7 @@ func (s *Service) GeneratePortalNDAFileURL(
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
compliancePage := &coredata.TrustCenter{}
compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err)
}
@@ -137,7 +137,7 @@ func (s *Service) GetPortalEmailPresenterConfig(
compliancePageID gid.GID,
) (emails.PresenterConfig, error) {
var (
compliancePage = &coredata.TrustCenter{}
compliancePage = &coredata.CompliancePortal{}
organization = &coredata.Organization{}
logoFile = &coredata.File{}
compliancePageURL string
@@ -161,7 +161,7 @@ func (s *Service) GetPortalEmailPresenterConfig(
return fmt.Errorf("cannot load organization: %w", err)
}
publicURL, err := s.management.PublicURLForCompliancePage(
publicURL, err := s.management.PublicURLForCompliancePortal(
ctx,
conn,
scope,

View File

@@ -95,8 +95,8 @@ func NewService(
func (s *Service) GetPortalByID(
ctx context.Context,
id gid.GID,
) (*coredata.TrustCenter, error) {
compliancePage := &coredata.TrustCenter{}
) (*coredata.CompliancePortal, error) {
compliancePage := &coredata.CompliancePortal{}
err := s.pg.WithConn(
ctx,
@@ -130,12 +130,12 @@ func (s *Service) GetPortalEffectiveCanonicalHost(ctx context.Context, complianc
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
compliancePage := &coredata.TrustCenter{}
compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, coredata.NewNoScope(), compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err)
}
domain, err := s.management.EffectiveDomainForCompliancePage(ctx, conn, coredata.NewNoScope(), compliancePage)
domain, err := s.management.EffectiveDomainForCompliancePortal(ctx, conn, coredata.NewNoScope(), compliancePage)
if err != nil {
return err
}
@@ -186,8 +186,8 @@ func (s *Service) GetPortalCanonicalBaseURL(
return parsed.String(), nil
}
func (s *Service) GetPortalByDomainName(ctx context.Context, domain string) (*coredata.TrustCenter, error) {
compliancePage := &coredata.TrustCenter{}
func (s *Service) GetPortalByDomainName(ctx context.Context, domain string) (*coredata.CompliancePortal, error) {
compliancePage := &coredata.CompliancePortal{}
err := s.pg.WithConn(
ctx,
@@ -201,7 +201,7 @@ func (s *Service) GetPortalByDomainName(ctx context.Context, domain string) (*co
return fmt.Errorf("cannot load custom domain: %w", err)
}
compliancePage = &coredata.TrustCenter{}
compliancePage = &coredata.CompliancePortal{}
if err := compliancePage.LoadByDomainID(ctx, conn, customDomain.ID); err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrPageNotFound
@@ -224,7 +224,7 @@ func (s *Service) GetPortalByDomainName(ctx context.Context, domain string) (*co
// the compliance page that belongs to the given organization. This is used by the
// esign certificate worker which needs per-org branding at render time.
func (s *Service) GetPortalEmailPresenterConfigByOrganizationID(ctx context.Context, orgID gid.GID) (emails.PresenterConfig, error) {
var compliancePage coredata.TrustCenter
var compliancePage coredata.CompliancePortal
scope := coredata.NewScopeFromObjectID(orgID)
@@ -265,13 +265,13 @@ func (s *Service) GetPortalOrganization(
return org, nil
}
func (s *Service) GetPortalMembership(ctx context.Context, compliancePageID gid.GID, identityID gid.GID) (*coredata.TrustCenterAccess, error) {
membership := &coredata.TrustCenterAccess{}
func (s *Service) GetPortalMembership(ctx context.Context, compliancePageID gid.GID, identityID gid.GID) (*coredata.CompliancePortalAccess, error) {
membership := &coredata.CompliancePortalAccess{}
err := s.pg.WithConn(
ctx,
func(ctx context.Context, conn pg.Querier) error {
return membership.LoadByTrustCenterIDAndIdentityID(
return membership.LoadByCompliancePortalIDAndIdentityID(
ctx,
conn,
coredata.NewScopeFromObjectID(compliancePageID),
@@ -295,9 +295,9 @@ func (s *Service) ProvisionPortalMember(
ctx context.Context,
compliancePageID gid.GID,
identityID gid.GID,
) (*coredata.TrustCenterAccess, error) {
) (*coredata.CompliancePortalAccess, error) {
var (
access *coredata.TrustCenterAccess
access *coredata.CompliancePortalAccess
now = time.Now()
scope = coredata.NewScopeFromObjectID(compliancePageID)
)
@@ -305,7 +305,7 @@ func (s *Service) ProvisionPortalMember(
err := s.pg.WithTx(
ctx,
func(ctx context.Context, tx pg.Tx) error {
compliancePage := &coredata.TrustCenter{}
compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, tx, scope, compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err)
}
@@ -315,20 +315,20 @@ func (s *Service) ProvisionPortalMember(
return fmt.Errorf("cannot load identity: %w", err)
}
access = &coredata.TrustCenterAccess{}
if err := access.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, compliancePageID, identityID); err != nil {
access = &coredata.CompliancePortalAccess{}
if err := access.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, compliancePageID, identityID); err != nil {
if !errors.Is(err, coredata.ErrResourceNotFound) {
return fmt.Errorf("cannot load compliance page access: %w", err)
}
access = &coredata.TrustCenterAccess{
ID: gid.New(scope.GetTenantID(), coredata.TrustCenterAccessEntityType),
OrganizationID: compliancePage.OrganizationID,
TenantID: scope.GetTenantID(),
IdentityID: identityID,
TrustCenterID: compliancePageID,
CreatedAt: now,
UpdatedAt: now,
access = &coredata.CompliancePortalAccess{
ID: gid.New(scope.GetTenantID(), coredata.CompliancePortalAccessEntityType),
OrganizationID: compliancePage.OrganizationID,
TenantID: scope.GetTenantID(),
IdentityID: identityID,
CompliancePortalID: compliancePageID,
CreatedAt: now,
UpdatedAt: now,
}
var sig *coredata.ElectronicSignature

View File

@@ -63,8 +63,8 @@ func (s *Service) ListThirdPartiesForOrganizationID(
filter *coredata.ThirdPartyFilter,
) (*page.Page[*coredata.ThirdParty, coredata.ThirdPartyOrderField], error) {
if filter == nil {
showOnTrustCenter := true
filter = coredata.NewThirdPartyFilter(&showOnTrustCenter, nil, nil, nil, nil)
showOnCompliancePortal := true
filter = coredata.NewThirdPartyFilter(&showOnCompliancePortal, nil, nil, nil, nil)
}
var thirdParties coredata.ThirdParties
@@ -99,7 +99,7 @@ func (s *Service) ListDistinctPortalCategoriesForOrganizationID(
func(ctx context.Context, conn pg.Querier) error {
thirdParties := &coredata.ThirdParties{}
result, err := thirdParties.LoadDistinctTrustCenterCategoriesByOrganizationID(ctx, conn, scope, organizationID)
result, err := thirdParties.LoadDistinctCompliancePortalCategoriesByOrganizationID(ctx, conn, scope, organizationID)
if err != nil {
return fmt.Errorf("cannot load thirdParty categories: %w", err)
}
@@ -128,7 +128,7 @@ func (s *Service) ListDistinctPortalCountriesForOrganizationID(
func(ctx context.Context, conn pg.Querier) error {
thirdParties := &coredata.ThirdParties{}
result, err := thirdParties.LoadDistinctTrustCenterCountriesByOrganizationID(ctx, conn, scope, organizationID)
result, err := thirdParties.LoadDistinctCompliancePortalCountriesByOrganizationID(ctx, conn, scope, organizationID)
if err != nil {
return fmt.Errorf("cannot load thirdParty countries: %w", err)
}
@@ -152,8 +152,8 @@ func (s *Service) CountThirdPartiesForPortalID(
filter *coredata.ThirdPartyFilter,
) (int, error) {
if filter == nil {
showOnTrustCenter := true
filter = coredata.NewThirdPartyFilter(&showOnTrustCenter, nil, nil, nil, nil)
showOnCompliancePortal := true
filter = coredata.NewThirdPartyFilter(&showOnCompliancePortal, nil, nil, nil, nil)
}
var count int