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:
@@ -38,32 +38,32 @@ import (
|
||||
|
||||
type (
|
||||
CreateAccessRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
IdentityID gid.GID
|
||||
CompliancePortalID gid.GID
|
||||
IdentityID gid.GID
|
||||
}
|
||||
|
||||
UpdateDocumentAccessRequest struct {
|
||||
ID gid.GID
|
||||
Status coredata.TrustCenterDocumentAccessStatus
|
||||
Status coredata.CompliancePortalDocumentAccessStatus
|
||||
}
|
||||
|
||||
UpdateAccessRequest struct {
|
||||
ID gid.GID
|
||||
DocumentAccesses []UpdateDocumentAccessRequest
|
||||
ReportAccesses []UpdateDocumentAccessRequest
|
||||
TrustCenterFileAccesses []UpdateDocumentAccessRequest
|
||||
ID gid.GID
|
||||
DocumentAccesses []UpdateDocumentAccessRequest
|
||||
ReportAccesses []UpdateDocumentAccessRequest
|
||||
CompliancePortalFileAccesses []UpdateDocumentAccessRequest
|
||||
}
|
||||
|
||||
AccessData struct {
|
||||
TrustCenterID gid.GID `json:"trust_center_id"`
|
||||
Email mail.Addr `json:"email"`
|
||||
CompliancePortalID gid.GID `json:"trust_center_id"`
|
||||
Email mail.Addr `json:"email"`
|
||||
}
|
||||
)
|
||||
|
||||
func (utcar *UpdateAccessRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(utcar.ID, "id", validator.Required(), validator.GID(coredata.TrustCenterAccessEntityType))
|
||||
v.Check(utcar.ID, "id", validator.Required(), validator.GID(coredata.CompliancePortalAccessEntityType))
|
||||
|
||||
for i, docAccess := range utcar.DocumentAccesses {
|
||||
v.Check(docAccess.ID, fmt.Sprintf("documentAccesses[%d].ID", i), validator.Required(), validator.GID(coredata.DocumentEntityType))
|
||||
@@ -73,8 +73,8 @@ func (utcar *UpdateAccessRequest) Validate() error {
|
||||
v.Check(reportAccess.ID, fmt.Sprintf("reportAccesses[%d].ID", i), validator.Required(), validator.GID(coredata.FileEntityType))
|
||||
}
|
||||
|
||||
for i, reportAccess := range utcar.TrustCenterFileAccesses {
|
||||
v.Check(reportAccess.ID, fmt.Sprintf("trustCenterFileAccesses[%d].ID", i), validator.Required(), validator.GID(coredata.TrustCenterFileEntityType))
|
||||
for i, reportAccess := range utcar.CompliancePortalFileAccesses {
|
||||
v.Check(reportAccess.ID, fmt.Sprintf("compliancePortalFileAccesses[%d].ID", i), validator.Required(), validator.GID(coredata.CompliancePortalFileEntityType))
|
||||
}
|
||||
|
||||
return v.Error()
|
||||
@@ -84,14 +84,14 @@ func (s *Service) ListAccesses(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
compliancePageID gid.GID,
|
||||
cursor *page.Cursor[coredata.TrustCenterAccessOrderField],
|
||||
) (*page.Page[*coredata.TrustCenterAccess, coredata.TrustCenterAccessOrderField], error) {
|
||||
var accesses coredata.TrustCenterAccesses
|
||||
cursor *page.Cursor[coredata.CompliancePortalAccessOrderField],
|
||||
) (*page.Page[*coredata.CompliancePortalAccess, coredata.CompliancePortalAccessOrderField], error) {
|
||||
var accesses coredata.CompliancePortalAccesses
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
return accesses.LoadByTrustCenterID(ctx, conn, scope, compliancePageID, cursor)
|
||||
return accesses.LoadByCompliancePortalID(ctx, conn, scope, compliancePageID, cursor)
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -104,15 +104,15 @@ func (s *Service) ListAccesses(
|
||||
func (s *Service) ListAvailableDocumentAccesses(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
cursor *page.Cursor[coredata.TrustCenterDocumentAccessOrderField],
|
||||
) (*page.Page[*coredata.TrustCenterDocumentAccess, coredata.TrustCenterDocumentAccessOrderField], error) {
|
||||
var documentAccesses coredata.TrustCenterDocumentAccesses
|
||||
compliancePortalAccessID gid.GID,
|
||||
cursor *page.Cursor[coredata.CompliancePortalDocumentAccessOrderField],
|
||||
) (*page.Page[*coredata.CompliancePortalDocumentAccess, coredata.CompliancePortalDocumentAccessOrderField], error) {
|
||||
var documentAccesses coredata.CompliancePortalDocumentAccesses
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
return documentAccesses.LoadAvailableByTrustCenterAccessID(ctx, conn, scope, trustCenterAccessID, cursor)
|
||||
return documentAccesses.LoadAvailableByCompliancePortalAccessID(ctx, conn, scope, compliancePortalAccessID, cursor)
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -126,8 +126,8 @@ func (s *Service) GetAccess(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
accessID gid.GID,
|
||||
) (*coredata.TrustCenterAccess, error) {
|
||||
var access coredata.TrustCenterAccess
|
||||
) (*coredata.CompliancePortalAccess, error) {
|
||||
var access coredata.CompliancePortalAccess
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -145,7 +145,7 @@ func (s *Service) GetAccess(
|
||||
func (s *Service) CountDocumentAccesses(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
) (int, error) {
|
||||
var count int
|
||||
|
||||
@@ -153,11 +153,11 @@ func (s *Service) CountDocumentAccesses(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
var (
|
||||
documentAccesses coredata.TrustCenterDocumentAccesses
|
||||
documentAccesses coredata.CompliancePortalDocumentAccesses
|
||||
err error
|
||||
)
|
||||
|
||||
count, err = documentAccesses.CountByTrustCenterAccessID(ctx, conn, scope, trustCenterAccessID)
|
||||
count, err = documentAccesses.CountByCompliancePortalAccessID(ctx, conn, scope, compliancePortalAccessID)
|
||||
|
||||
return err
|
||||
},
|
||||
@@ -172,7 +172,7 @@ func (s *Service) CountDocumentAccesses(
|
||||
func (s *Service) CountPendingRequestDocumentAccesses(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
) (int, error) {
|
||||
var count int
|
||||
|
||||
@@ -180,11 +180,11 @@ func (s *Service) CountPendingRequestDocumentAccesses(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
var (
|
||||
documentAccesses coredata.TrustCenterDocumentAccesses
|
||||
documentAccesses coredata.CompliancePortalDocumentAccesses
|
||||
err error
|
||||
)
|
||||
|
||||
count, err = documentAccesses.CountPendingRequestByTrustCenterAccessID(ctx, conn, scope, trustCenterAccessID)
|
||||
count, err = documentAccesses.CountPendingRequestByCompliancePortalAccessID(ctx, conn, scope, compliancePortalAccessID)
|
||||
|
||||
return err
|
||||
},
|
||||
@@ -199,7 +199,7 @@ func (s *Service) CountPendingRequestDocumentAccesses(
|
||||
func (s *Service) CountActiveDocumentAccesses(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
) (int, error) {
|
||||
var count int
|
||||
|
||||
@@ -207,11 +207,11 @@ func (s *Service) CountActiveDocumentAccesses(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
var (
|
||||
documentAccesses coredata.TrustCenterDocumentAccesses
|
||||
documentAccesses coredata.CompliancePortalDocumentAccesses
|
||||
err error
|
||||
)
|
||||
|
||||
count, err = documentAccesses.CountActiveByTrustCenterAccessID(ctx, conn, scope, trustCenterAccessID)
|
||||
count, err = documentAccesses.CountActiveByCompliancePortalAccessID(ctx, conn, scope, compliancePortalAccessID)
|
||||
|
||||
return err
|
||||
},
|
||||
@@ -227,34 +227,34 @@ func (s *Service) UpdateAccess(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UpdateAccessRequest,
|
||||
) (*coredata.TrustCenterAccess, error) {
|
||||
) (*coredata.CompliancePortalAccess, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
access *coredata.TrustCenterAccess
|
||||
trustCenterAcessActivated bool
|
||||
shouldUpdateSlackMessage bool
|
||||
access *coredata.CompliancePortalAccess
|
||||
compliancePortalAcessActivated bool
|
||||
shouldUpdateSlackMessage bool
|
||||
)
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
access = &coredata.TrustCenterAccess{}
|
||||
access = &coredata.CompliancePortalAccess{}
|
||||
|
||||
if err := access.LoadByID(ctx, tx, scope, req.ID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page access: %w", err)
|
||||
}
|
||||
|
||||
var tcdas coredata.TrustCenterDocumentAccesses
|
||||
var tcdas coredata.CompliancePortalDocumentAccesses
|
||||
|
||||
if len(req.DocumentAccesses) > 0 {
|
||||
var documentData []coredata.MergeTrustCenterDocumentAccessesData
|
||||
var documentData []coredata.MergeCompliancePortalDocumentAccessesData
|
||||
|
||||
documentIDs := make([]gid.GID, 0, len(req.DocumentAccesses))
|
||||
for _, d := range req.DocumentAccesses {
|
||||
documentData = append(documentData, coredata.MergeTrustCenterDocumentAccessesData{
|
||||
documentData = append(documentData, coredata.MergeCompliancePortalDocumentAccessesData{
|
||||
ID: d.ID,
|
||||
Status: d.Status,
|
||||
})
|
||||
@@ -273,11 +273,11 @@ func (s *Service) UpdateAccess(
|
||||
}
|
||||
|
||||
if len(req.ReportAccesses) > 0 {
|
||||
var reportData []coredata.MergeTrustCenterDocumentAccessesData
|
||||
var reportData []coredata.MergeCompliancePortalDocumentAccessesData
|
||||
|
||||
reportIDs := make([]gid.GID, 0, len(req.ReportAccesses))
|
||||
for _, d := range req.ReportAccesses {
|
||||
reportData = append(reportData, coredata.MergeTrustCenterDocumentAccessesData{
|
||||
reportData = append(reportData, coredata.MergeCompliancePortalDocumentAccessesData{
|
||||
ID: d.ID,
|
||||
Status: d.Status,
|
||||
})
|
||||
@@ -295,39 +295,39 @@ func (s *Service) UpdateAccess(
|
||||
}
|
||||
}
|
||||
|
||||
if len(req.TrustCenterFileAccesses) > 0 {
|
||||
var fileData []coredata.MergeTrustCenterDocumentAccessesData
|
||||
if len(req.CompliancePortalFileAccesses) > 0 {
|
||||
var fileData []coredata.MergeCompliancePortalDocumentAccessesData
|
||||
|
||||
trustCenterFileIDs := make([]gid.GID, 0, len(req.TrustCenterFileAccesses))
|
||||
for _, d := range req.TrustCenterFileAccesses {
|
||||
fileData = append(fileData, coredata.MergeTrustCenterDocumentAccessesData{
|
||||
compliancePortalFileIDs := make([]gid.GID, 0, len(req.CompliancePortalFileAccesses))
|
||||
for _, d := range req.CompliancePortalFileAccesses {
|
||||
fileData = append(fileData, coredata.MergeCompliancePortalDocumentAccessesData{
|
||||
ID: d.ID,
|
||||
Status: d.Status,
|
||||
})
|
||||
|
||||
trustCenterFileIDs = append(trustCenterFileIDs, d.ID)
|
||||
compliancePortalFileIDs = append(compliancePortalFileIDs, d.ID)
|
||||
}
|
||||
|
||||
trustCenterFiles := &coredata.TrustCenterFiles{}
|
||||
if err := trustCenterFiles.LoadByIDs(ctx, tx, scope, trustCenterFileIDs); err != nil {
|
||||
compliancePortalFiles := &coredata.CompliancePortalFiles{}
|
||||
if err := compliancePortalFiles.LoadByIDs(ctx, tx, scope, compliancePortalFileIDs); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page files: %w", err)
|
||||
}
|
||||
|
||||
if err := tcdas.MergeTrustCenterFileAccesses(ctx, tx, scope, access.OrganizationID, access.ID, fileData); err != nil {
|
||||
if err := tcdas.MergeCompliancePortalFileAccesses(ctx, tx, scope, access.OrganizationID, access.ID, fileData); err != nil {
|
||||
return fmt.Errorf("cannot merge compliance page file accesses: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if trustCenterAcessActivated {
|
||||
if compliancePortalAcessActivated {
|
||||
if err := s.sendAccessEmail(ctx, scope, tx, access); err != nil {
|
||||
return fmt.Errorf("cannot send access email: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
shouldUpdateSlackMessage = trustCenterAcessActivated ||
|
||||
shouldUpdateSlackMessage = compliancePortalAcessActivated ||
|
||||
len(req.DocumentAccesses) > 0 ||
|
||||
len(req.ReportAccesses) > 0 ||
|
||||
len(req.TrustCenterFileAccesses) > 0
|
||||
len(req.CompliancePortalFileAccesses) > 0
|
||||
|
||||
return nil
|
||||
},
|
||||
@@ -337,7 +337,7 @@ func (s *Service) UpdateAccess(
|
||||
}
|
||||
|
||||
if shouldUpdateSlackMessage {
|
||||
if err := s.SlackMessages.QueueSlackNotification(ctx, scope, access.IdentityID, access.TrustCenterID); err != nil {
|
||||
if err := s.SlackMessages.QueueSlackNotification(ctx, scope, access.IdentityID, access.CompliancePortalID); err != nil {
|
||||
if !errors.Is(err, slack.ErrNoSlackConnector) {
|
||||
return nil, fmt.Errorf("cannot queue slack notification: %w", err)
|
||||
}
|
||||
@@ -350,14 +350,14 @@ func (s *Service) UpdateAccess(
|
||||
func (s *Service) DeleteAccess(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
) error {
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
access := &coredata.TrustCenterAccess{}
|
||||
access := &coredata.CompliancePortalAccess{}
|
||||
|
||||
if err := access.LoadByID(ctx, tx, scope, trustCenterAccessID); err != nil {
|
||||
if err := access.LoadByID(ctx, tx, scope, compliancePortalAccessID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page access: %w", err)
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ func (s *Service) sendAccessEmail(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
tx pg.Tx,
|
||||
access *coredata.TrustCenterAccess,
|
||||
access *coredata.CompliancePortalAccess,
|
||||
) error {
|
||||
organization := &coredata.Organization{}
|
||||
if err := organization.LoadByID(ctx, tx, scope, access.OrganizationID); err != nil {
|
||||
@@ -401,14 +401,14 @@ func (s *Service) sendAccessEmail(
|
||||
return fmt.Errorf("cannot load profile: %w", err)
|
||||
}
|
||||
|
||||
emailPresenterCfg, err := s.EmailPresenterConfig(ctx, scope, access.TrustCenterID)
|
||||
emailPresenterCfg, err := s.EmailPresenterConfig(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)
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ import (
|
||||
|
||||
type (
|
||||
CreateCompliancePortalCommitmentGroupRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
Title string
|
||||
Description string
|
||||
CompliancePortalID gid.GID
|
||||
Title string
|
||||
Description string
|
||||
}
|
||||
|
||||
UpdateCompliancePortalCommitmentGroupRequest struct {
|
||||
@@ -50,7 +50,7 @@ type (
|
||||
func (r *CreateCompliancePortalCommitmentGroupRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(r.TrustCenterID, "trust_center_id", validator.Required(), validator.GID(coredata.TrustCenterEntityType))
|
||||
v.Check(r.CompliancePortalID, "trust_center_id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
|
||||
v.Check(r.Title, "title", validator.Required(), validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(r.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
|
||||
@@ -70,7 +70,7 @@ func (r *UpdateCompliancePortalCommitmentGroupRequest) Validate() error {
|
||||
func (s *Service) ListCommitmentGroups(
|
||||
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
|
||||
@@ -78,7 +78,7 @@ func (s *Service) ListCommitmentGroups(
|
||||
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)
|
||||
}
|
||||
@@ -96,7 +96,7 @@ func (s *Service) ListCommitmentGroups(
|
||||
func (s *Service) CountCommitmentGroups(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
) (int, error) {
|
||||
var count int
|
||||
|
||||
@@ -105,7 +105,7 @@ func (s *Service) CountCommitmentGroups(
|
||||
func(ctx context.Context, conn pg.Querier) (err error) {
|
||||
groups := coredata.CompliancePortalCommitmentGroups{}
|
||||
|
||||
count, err = groups.CountByTrustCenterID(ctx, conn, scope, trustCenterID)
|
||||
count, err = groups.CountByCompliancePortalID(ctx, conn, scope, compliancePortalID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot count compliance portal commitment groups: %w", err)
|
||||
}
|
||||
@@ -163,19 +163,19 @@ func (s *Service) CreateCommitmentGroup(
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
trustCenter := &coredata.TrustCenter{}
|
||||
if err := trustCenter.LoadByID(ctx, tx, scope, req.TrustCenterID); err != nil {
|
||||
return fmt.Errorf("cannot load trust center: %w", err)
|
||||
compliancePortal := &coredata.CompliancePortal{}
|
||||
if err := compliancePortal.LoadByID(ctx, tx, scope, req.CompliancePortalID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal: %w", err)
|
||||
}
|
||||
|
||||
group = &coredata.CompliancePortalCommitmentGroup{
|
||||
ID: groupID,
|
||||
OrganizationID: trustCenter.OrganizationID,
|
||||
TrustCenterID: req.TrustCenterID,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: groupID,
|
||||
OrganizationID: compliancePortal.OrganizationID,
|
||||
CompliancePortalID: req.CompliancePortalID,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := group.Insert(ctx, tx, scope); err != nil {
|
||||
|
||||
@@ -181,16 +181,16 @@ func (s *Service) CreateCommitment(
|
||||
}
|
||||
|
||||
commitment = &coredata.CompliancePortalCommitment{
|
||||
ID: commitmentID,
|
||||
OrganizationID: group.OrganizationID,
|
||||
TrustCenterID: group.TrustCenterID,
|
||||
GroupID: req.GroupID,
|
||||
Icon: req.Icon,
|
||||
Eyebrow: req.Eyebrow,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: commitmentID,
|
||||
OrganizationID: group.OrganizationID,
|
||||
CompliancePortalID: group.CompliancePortalID,
|
||||
GroupID: req.GroupID,
|
||||
Icon: req.Icon,
|
||||
Eyebrow: req.Eyebrow,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := commitment.Insert(ctx, tx, scope); err != nil {
|
||||
|
||||
@@ -34,9 +34,9 @@ import (
|
||||
|
||||
type (
|
||||
CreateCustomLinkRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
Name string
|
||||
URL string
|
||||
CompliancePortalID gid.GID
|
||||
Name string
|
||||
URL string
|
||||
}
|
||||
|
||||
UpdateCustomLinkRequest struct {
|
||||
@@ -53,7 +53,7 @@ type (
|
||||
|
||||
func (r *CreateCustomLinkRequest) Validate() error {
|
||||
v := validator.New()
|
||||
v.Check(r.TrustCenterID, "trust_center_id", validator.Required(), validator.GID(coredata.TrustCenterEntityType))
|
||||
v.Check(r.CompliancePortalID, "trust_center_id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
|
||||
v.Check(r.URL, "url", validator.Required(), validator.URL())
|
||||
|
||||
return v.Error()
|
||||
@@ -86,7 +86,7 @@ func (s *Service) ListCustomLinks(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
if err := items.LoadByTrustCenterID(ctx, conn, scope, compliancePageID, cursor); err != nil {
|
||||
if err := items.LoadByCompliancePortalID(ctx, conn, scope, compliancePageID, cursor); err != nil {
|
||||
return fmt.Errorf("cannot load custom links: %w", err)
|
||||
}
|
||||
|
||||
@@ -117,19 +117,19 @@ func (s *Service) CreateCustomLink(
|
||||
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)
|
||||
}
|
||||
|
||||
item = &coredata.ComplianceCustomLink{
|
||||
ID: id,
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
TrustCenterID: req.TrustCenterID,
|
||||
Name: req.Name,
|
||||
URL: req.URL,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: id,
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
CompliancePortalID: req.CompliancePortalID,
|
||||
Name: req.Name,
|
||||
URL: req.URL,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := item.Insert(ctx, tx, scope); err != nil {
|
||||
|
||||
@@ -23,11 +23,11 @@ import (
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
)
|
||||
|
||||
func (s *Service) EffectiveDomainForCompliancePage(
|
||||
func (s *Service) EffectiveDomainForCompliancePortal(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope coredata.Scoper,
|
||||
compliancePage *coredata.TrustCenter,
|
||||
compliancePage *coredata.CompliancePortal,
|
||||
) (*coredata.CustomDomain, error) {
|
||||
byID, active, err := loadDomains(ctx, conn, scope, compliancePage)
|
||||
if err != nil {
|
||||
@@ -49,11 +49,11 @@ func (s *Service) EffectiveDomainForCompliancePage(
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Service) PublicURLForCompliancePage(
|
||||
func (s *Service) PublicURLForCompliancePortal(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope coredata.Scoper,
|
||||
compliancePage *coredata.TrustCenter,
|
||||
compliancePage *coredata.CompliancePortal,
|
||||
) (string, error) {
|
||||
byID, active, err := loadDomains(ctx, conn, scope, compliancePage)
|
||||
if err != nil {
|
||||
@@ -80,7 +80,7 @@ func loadDomains(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope coredata.Scoper,
|
||||
compliancePage *coredata.TrustCenter,
|
||||
compliancePage *coredata.CompliancePortal,
|
||||
) (map[gid.GID]*coredata.CustomDomain, map[gid.GID]bool, error) {
|
||||
var ids []gid.GID
|
||||
if compliancePage.CustomDomainID != nil {
|
||||
|
||||
@@ -35,7 +35,7 @@ func (s *Service) AddCustomDomain(
|
||||
domain string,
|
||||
) (*coredata.CustomDomain, error) {
|
||||
v := validator.New()
|
||||
v.Check(compliancePageID, "compliance_page_id", validator.Required(), validator.GID(coredata.TrustCenterEntityType))
|
||||
v.Check(compliancePageID, "compliance_page_id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
|
||||
v.Check(domain, "domain", validator.Required(), validator.NotEmpty(), validator.Domain())
|
||||
|
||||
if err := v.Error(); err != nil {
|
||||
@@ -47,7 +47,7 @@ func (s *Service) AddCustomDomain(
|
||||
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)
|
||||
}
|
||||
@@ -107,7 +107,7 @@ func (s *Service) RemoveCustomDomain(
|
||||
return ErrCustomDomainManaged
|
||||
}
|
||||
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
|
||||
err := compliancePage.LoadByDomainID(ctx, tx, customDomainID)
|
||||
switch {
|
||||
@@ -177,14 +177,14 @@ func (s *Service) PublicURL(
|
||||
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)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
publicURL, err = s.PublicURLForCompliancePage(ctx, conn, scope, compliancePage)
|
||||
publicURL, err = s.PublicURLForCompliancePortal(ctx, conn, scope, compliancePage)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot resolve public url: %w", err)
|
||||
}
|
||||
|
||||
@@ -41,18 +41,18 @@ import (
|
||||
|
||||
type (
|
||||
CreateFileRequest struct {
|
||||
OrganizationID gid.GID
|
||||
Name string
|
||||
Category string
|
||||
File File
|
||||
TrustCenterVisibility coredata.TrustCenterVisibility
|
||||
OrganizationID gid.GID
|
||||
Name string
|
||||
Category string
|
||||
File File
|
||||
CompliancePortalVisibility coredata.CompliancePortalVisibility
|
||||
}
|
||||
|
||||
UpdateFileRequest struct {
|
||||
ID gid.GID
|
||||
Name *string
|
||||
Category *string
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility
|
||||
ID gid.GID
|
||||
Name *string
|
||||
Category *string
|
||||
CompliancePortalVisibility *coredata.CompliancePortalVisibility
|
||||
}
|
||||
)
|
||||
|
||||
@@ -63,7 +63,7 @@ func (ctcfr *CreateFileRequest) Validate() error {
|
||||
v.Check(ctcfr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(ctcfr.Category, "category", validator.Required(), validator.SafeText(TitleMaxLength))
|
||||
v.Check(ctcfr.File, "file", validator.Required())
|
||||
v.Check(ctcfr.TrustCenterVisibility, "trust_center_visibility", validator.Required(), validator.OneOfSlice(coredata.TrustCenterVisibilities()))
|
||||
v.Check(ctcfr.CompliancePortalVisibility, "trust_center_visibility", validator.Required(), validator.OneOfSlice(coredata.CompliancePortalVisibilities()))
|
||||
|
||||
return v.Error()
|
||||
}
|
||||
@@ -71,10 +71,10 @@ func (ctcfr *CreateFileRequest) Validate() error {
|
||||
func (utcfr *UpdateFileRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(utcfr.ID, "id", validator.Required(), validator.GID(coredata.TrustCenterFileEntityType))
|
||||
v.Check(utcfr.ID, "id", validator.Required(), validator.GID(coredata.CompliancePortalFileEntityType))
|
||||
v.Check(utcfr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(utcfr.Category, "category", validator.SafeText(TitleMaxLength))
|
||||
v.Check(utcfr.TrustCenterVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.TrustCenterVisibilities()))
|
||||
v.Check(utcfr.CompliancePortalVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.CompliancePortalVisibilities()))
|
||||
|
||||
return v.Error()
|
||||
}
|
||||
@@ -83,10 +83,10 @@ func (s *Service) ListFilesForOrganizationID(
|
||||
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 files coredata.TrustCenterFiles
|
||||
cursor *page.Cursor[coredata.CompliancePortalFileOrderField],
|
||||
filter *coredata.CompliancePortalFileFilter,
|
||||
) (*page.Page[*coredata.CompliancePortalFile, coredata.CompliancePortalFileOrderField], error) {
|
||||
var files coredata.CompliancePortalFiles
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -116,7 +116,7 @@ func (s *Service) CountFilesForOrganizationID(
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
var err error
|
||||
|
||||
count, err = (&coredata.TrustCenterFiles{}).CountByOrganizationID(ctx, conn, scope, organizationID)
|
||||
count, err = (&coredata.CompliancePortalFiles{}).CountByOrganizationID(ctx, conn, scope, organizationID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot count compliance page files: %w", err)
|
||||
}
|
||||
@@ -134,13 +134,13 @@ func (s *Service) GetFile(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
id gid.GID,
|
||||
) (*coredata.TrustCenterFile, error) {
|
||||
var file *coredata.TrustCenterFile
|
||||
) (*coredata.CompliancePortalFile, error) {
|
||||
var file *coredata.CompliancePortalFile
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
file = &coredata.TrustCenterFile{}
|
||||
file = &coredata.CompliancePortalFile{}
|
||||
if err := file.LoadByID(ctx, conn, scope, id); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page file: %w", err)
|
||||
}
|
||||
@@ -159,7 +159,7 @@ func (s *Service) CreateFile(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *CreateFileRequest,
|
||||
) (*coredata.TrustCenterFile, error) {
|
||||
) (*coredata.CompliancePortalFile, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -179,32 +179,32 @@ func (s *Service) CreateFile(
|
||||
|
||||
now := time.Now()
|
||||
|
||||
trustCenterFileID := gid.New(scope.GetTenantID(), coredata.TrustCenterFileEntityType)
|
||||
compliancePortalFileID := gid.New(scope.GetTenantID(), coredata.CompliancePortalFileEntityType)
|
||||
|
||||
var (
|
||||
file *coredata.TrustCenterFile
|
||||
file *coredata.CompliancePortalFile
|
||||
s3Key string
|
||||
)
|
||||
|
||||
err = s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
fileID, objectKey, err := s.uploadFile(ctx, scope, tx, req.File, trustCenterFileID, req.OrganizationID, now)
|
||||
fileID, objectKey, err := s.uploadFile(ctx, scope, tx, req.File, compliancePortalFileID, req.OrganizationID, now)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot upload file: %w", err)
|
||||
}
|
||||
|
||||
s3Key = objectKey
|
||||
|
||||
file = &coredata.TrustCenterFile{
|
||||
ID: trustCenterFileID,
|
||||
OrganizationID: req.OrganizationID,
|
||||
Name: req.Name,
|
||||
Category: req.Category,
|
||||
FileID: fileID,
|
||||
TrustCenterVisibility: req.TrustCenterVisibility,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
file = &coredata.CompliancePortalFile{
|
||||
ID: compliancePortalFileID,
|
||||
OrganizationID: req.OrganizationID,
|
||||
Name: req.Name,
|
||||
Category: req.Category,
|
||||
FileID: fileID,
|
||||
CompliancePortalVisibility: req.CompliancePortalVisibility,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := file.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -226,19 +226,19 @@ func (s *Service) UpdateFile(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UpdateFileRequest,
|
||||
) (*coredata.TrustCenterFile, error) {
|
||||
) (*coredata.CompliancePortalFile, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
var file *coredata.TrustCenterFile
|
||||
var file *coredata.CompliancePortalFile
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
file = &coredata.TrustCenterFile{}
|
||||
file = &coredata.CompliancePortalFile{}
|
||||
|
||||
if err := file.LoadByID(ctx, tx, scope, req.ID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page file: %w", err)
|
||||
@@ -252,8 +252,8 @@ func (s *Service) UpdateFile(
|
||||
file.Category = *req.Category
|
||||
}
|
||||
|
||||
if req.TrustCenterVisibility != nil {
|
||||
file.TrustCenterVisibility = *req.TrustCenterVisibility
|
||||
if req.CompliancePortalVisibility != nil {
|
||||
file.CompliancePortalVisibility = *req.CompliancePortalVisibility
|
||||
}
|
||||
|
||||
file.UpdatedAt = now
|
||||
@@ -275,14 +275,14 @@ func (s *Service) UpdateFile(
|
||||
func (s *Service) DeleteFile(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterFileID gid.GID,
|
||||
compliancePortalFileID gid.GID,
|
||||
) error {
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
file := &coredata.TrustCenterFile{}
|
||||
file := &coredata.CompliancePortalFile{}
|
||||
|
||||
if err := file.LoadByID(ctx, tx, scope, trustCenterFileID); err != nil {
|
||||
if err := file.LoadByID(ctx, tx, scope, compliancePortalFileID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page file: %w", err)
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ func (s *Service) DeleteFile(
|
||||
func (s *Service) GenerateFileURL(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterFileID gid.GID,
|
||||
compliancePortalFileID gid.GID,
|
||||
duration time.Duration,
|
||||
) (string, error) {
|
||||
var storedFile *coredata.File
|
||||
@@ -307,8 +307,8 @@ func (s *Service) GenerateFileURL(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
file := &coredata.TrustCenterFile{}
|
||||
if err := file.LoadByID(ctx, conn, scope, trustCenterFileID); err != nil {
|
||||
file := &coredata.CompliancePortalFile{}
|
||||
if err := file.LoadByID(ctx, conn, scope, compliancePortalFileID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page file: %w", err)
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ func (s *Service) uploadFile(
|
||||
scope coredata.Scoper,
|
||||
tx pg.Tx,
|
||||
file File,
|
||||
trustCenterFileID gid.GID,
|
||||
compliancePortalFileID gid.GID,
|
||||
organizationID gid.GID,
|
||||
now time.Time,
|
||||
) (gid.GID, string, error) {
|
||||
@@ -404,7 +404,7 @@ func (s *Service) uploadFile(
|
||||
CacheControl: new("private, max-age=3600"),
|
||||
Metadata: map[string]string{
|
||||
"type": "compliance-page-file",
|
||||
"compliance-page-file-id": trustCenterFileID.String(),
|
||||
"compliance-page-file-id": compliancePortalFileID.String(),
|
||||
"organization-id": organizationID.String(),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -34,8 +34,8 @@ import (
|
||||
|
||||
type (
|
||||
CreateFrameworkRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
FrameworkID gid.GID
|
||||
CompliancePortalID gid.GID
|
||||
FrameworkID gid.GID
|
||||
}
|
||||
|
||||
UpdateFrameworkRequest struct {
|
||||
@@ -51,7 +51,7 @@ type (
|
||||
func (r *CreateFrameworkRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(r.TrustCenterID, "trust_center_id", validator.Required(), validator.GID(coredata.TrustCenterEntityType))
|
||||
v.Check(r.CompliancePortalID, "trust_center_id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
|
||||
v.Check(r.FrameworkID, "framework_id", validator.Required(), validator.GID(coredata.FrameworkEntityType))
|
||||
|
||||
return v.Error()
|
||||
@@ -84,7 +84,7 @@ func (s *Service) ListFrameworksWithHidden(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
if err := cfs.LoadWithHiddenByTrustCenterID(ctx, conn, scope, compliancePageID, cursor); err != nil {
|
||||
if err := cfs.LoadWithHiddenByCompliancePortalID(ctx, conn, scope, compliancePageID, cursor); err != nil {
|
||||
return fmt.Errorf("cannot load frameworks with hidden: %w", err)
|
||||
}
|
||||
|
||||
@@ -116,8 +116,8 @@ func (s *Service) CreateFramework(
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -127,12 +127,12 @@ func (s *Service) CreateFramework(
|
||||
}
|
||||
|
||||
cf = &coredata.ComplianceFramework{
|
||||
ID: cfID,
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
TrustCenterID: req.TrustCenterID,
|
||||
FrameworkID: req.FrameworkID,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: cfID,
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
CompliancePortalID: req.CompliancePortalID,
|
||||
FrameworkID: req.FrameworkID,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := cf.Insert(ctx, tx, scope); err != nil {
|
||||
|
||||
@@ -54,15 +54,15 @@ type (
|
||||
}
|
||||
|
||||
UploadNDARequest struct {
|
||||
TrustCenterID gid.GID
|
||||
File io.Reader
|
||||
FileName string
|
||||
CompliancePortalID gid.GID
|
||||
File io.Reader
|
||||
FileName string
|
||||
}
|
||||
|
||||
UpdateBrandRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
LogoFile **FileUpload
|
||||
DarkLogoFile **FileUpload
|
||||
CompliancePortalID gid.GID
|
||||
LogoFile **FileUpload
|
||||
DarkLogoFile **FileUpload
|
||||
}
|
||||
)
|
||||
|
||||
@@ -71,7 +71,7 @@ const maxBrandFileSize = 5 * 1024 * 1024 // 5MB
|
||||
func (utcr *UpdateRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(utcr.ID, "id", validator.Required(), validator.GID(coredata.TrustCenterEntityType))
|
||||
v.Check(utcr.ID, "id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
|
||||
v.Check(utcr.Slug, "slug", validator.SafeText(NameMaxLength))
|
||||
v.Check(utcr.NonDisclosureAgreementFileID, "non_disclosure_agreement_file_id", validator.GID(coredata.FileEntityType))
|
||||
|
||||
@@ -101,7 +101,7 @@ func (utcr *UpdateRequest) Validate() error {
|
||||
func (utcndar *UploadNDARequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(utcndar.TrustCenterID, "trust_center_id", validator.Required(), validator.GID(coredata.TrustCenterEntityType))
|
||||
v.Check(utcndar.CompliancePortalID, "trust_center_id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
|
||||
v.Check(utcndar.FileName, "file_name", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
|
||||
return v.Error()
|
||||
@@ -134,13 +134,13 @@ func (s *Service) Get(
|
||||
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)
|
||||
}
|
||||
@@ -159,13 +159,13 @@ func (s *Service) GetByOrganizationID(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
organizationID 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.LoadByOrganizationID(ctx, conn, scope, organizationID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
@@ -184,20 +184,20 @@ func (s *Service) Update(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UpdateRequest,
|
||||
) (*coredata.TrustCenter, *coredata.File, error) {
|
||||
) (*coredata.CompliancePortal, *coredata.File, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
compliancePage *coredata.TrustCenter
|
||||
compliancePage *coredata.CompliancePortal
|
||||
file *coredata.File
|
||||
)
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Tx) error {
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, req.ID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
@@ -267,26 +267,26 @@ func (s *Service) UploadNDA(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UploadNDARequest,
|
||||
) (*coredata.TrustCenter, *coredata.File, error) {
|
||||
) (*coredata.CompliancePortal, *coredata.File, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
compliancePage *coredata.TrustCenter
|
||||
compliancePage *coredata.CompliancePortal
|
||||
file *coredata.File
|
||||
)
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Tx) error {
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, req.TrustCenterID); err != nil {
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, req.CompliancePortalID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
|
||||
if compliancePage.OrganizationID == gid.Nil {
|
||||
return fmt.Errorf("compliance page %s has no organization", req.TrustCenterID)
|
||||
return fmt.Errorf("compliance page %s has no organization", req.CompliancePortalID)
|
||||
}
|
||||
|
||||
objectKey, err := uuid.NewV7()
|
||||
@@ -320,7 +320,7 @@ func (s *Service) UploadNDA(
|
||||
req.File,
|
||||
map[string]string{
|
||||
"type": "compliance-page-nda",
|
||||
"compliance-page-id": req.TrustCenterID.String(),
|
||||
"compliance-page-id": req.CompliancePortalID.String(),
|
||||
"organization-id": compliancePage.OrganizationID.String(),
|
||||
},
|
||||
)
|
||||
@@ -355,13 +355,13 @@ func (s *Service) DeleteNDA(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
compliancePageID gid.GID,
|
||||
) (*coredata.TrustCenter, *coredata.File, error) {
|
||||
var compliancePage *coredata.TrustCenter
|
||||
) (*coredata.CompliancePortal, *coredata.File, error) {
|
||||
var compliancePage *coredata.CompliancePortal
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Tx) 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)
|
||||
}
|
||||
@@ -387,21 +387,21 @@ func (s *Service) UpdateBrand(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UpdateBrandRequest,
|
||||
) (*coredata.TrustCenter, *coredata.File, error) {
|
||||
) (*coredata.CompliancePortal, *coredata.File, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
compliancePage *coredata.TrustCenter
|
||||
compliancePage *coredata.CompliancePortal
|
||||
ndaFile *coredata.File
|
||||
)
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Tx) error {
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, req.TrustCenterID); err != nil {
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, req.CompliancePortalID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
|
||||
@@ -462,7 +462,7 @@ func (s *Service) uploadBrandFile(
|
||||
conn pg.Tx,
|
||||
fileUpload *FileUpload,
|
||||
fileType string,
|
||||
compliancePage *coredata.TrustCenter,
|
||||
compliancePage *coredata.CompliancePortal,
|
||||
) (*coredata.File, error) {
|
||||
objectKey, err := uuid.NewV7()
|
||||
if err != nil {
|
||||
@@ -529,7 +529,7 @@ func (s *Service) GenerateNDAFileURL(
|
||||
) (*string, error) {
|
||||
var file *coredata.File
|
||||
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -573,7 +573,7 @@ func (s *Service) GenerateLogoURL(
|
||||
expiresIn time.Duration,
|
||||
) (*string, error) {
|
||||
file := &coredata.File{}
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -620,7 +620,7 @@ func (s *Service) GenerateDarkLogoURL(
|
||||
expiresIn time.Duration,
|
||||
) (*string, error) {
|
||||
file := &coredata.File{}
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -666,7 +666,7 @@ func (s *Service) EmailPresenterConfig(
|
||||
compliancePageID gid.GID,
|
||||
) (emails.PresenterConfig, error) {
|
||||
var (
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
organization = &coredata.Organization{}
|
||||
logoFile = &coredata.File{}
|
||||
compliancePageURL string
|
||||
@@ -690,7 +690,7 @@ func (s *Service) EmailPresenterConfig(
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
publicURL, err := s.PublicURLForCompliancePage(ctx, conn, scope, compliancePage)
|
||||
publicURL, err := s.PublicURLForCompliancePortal(ctx, conn, scope, compliancePage)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot resolve compliance page URL: %w", err)
|
||||
}
|
||||
@@ -736,7 +736,7 @@ func (s *Service) GetMailingList(
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ import (
|
||||
|
||||
type (
|
||||
CreateReferenceRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
Name string
|
||||
Description *string
|
||||
WebsiteURL string
|
||||
LogoFile File
|
||||
CompliancePortalID gid.GID
|
||||
Name string
|
||||
Description *string
|
||||
WebsiteURL string
|
||||
LogoFile File
|
||||
}
|
||||
|
||||
UpdateReferenceRequest struct {
|
||||
@@ -60,7 +60,7 @@ type (
|
||||
func (ctcrr *CreateReferenceRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(ctcrr.TrustCenterID, "trust_center_id", validator.Required(), validator.GID(coredata.TrustCenterEntityType))
|
||||
v.Check(ctcrr.CompliancePortalID, "trust_center_id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
|
||||
v.Check(ctcrr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(ctcrr.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
v.Check(ctcrr.WebsiteURL, "website_url", validator.Required(), validator.SafeText(2048))
|
||||
@@ -71,7 +71,7 @@ func (ctcrr *CreateReferenceRequest) Validate() error {
|
||||
func (utcrr *UpdateReferenceRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(utcrr.ID, "id", validator.Required(), validator.GID(coredata.TrustCenterReferenceEntityType))
|
||||
v.Check(utcrr.ID, "id", validator.Required(), validator.GID(coredata.CompliancePortalReferenceEntityType))
|
||||
v.Check(utcrr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(utcrr.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
v.Check(utcrr.WebsiteURL, "website_url", validator.SafeText(2048))
|
||||
@@ -83,14 +83,14 @@ func (s *Service) ListReferences(
|
||||
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)
|
||||
}
|
||||
@@ -115,9 +115,9 @@ func (s *Service) CountReferences(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) (err error) {
|
||||
references := coredata.TrustCenterReferences{}
|
||||
references := coredata.CompliancePortalReferences{}
|
||||
|
||||
count, err = references.CountByTrustCenterID(ctx, conn, scope, compliancePageID)
|
||||
count, err = references.CountByCompliancePortalID(ctx, conn, scope, compliancePageID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot count compliance page references: %w", err)
|
||||
}
|
||||
@@ -136,8 +136,8 @@ func (s *Service) GetReference(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
referenceID gid.GID,
|
||||
) (*coredata.TrustCenterReference, error) {
|
||||
var reference coredata.TrustCenterReference
|
||||
) (*coredata.CompliancePortalReference, error) {
|
||||
var reference coredata.CompliancePortalReference
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -161,44 +161,44 @@ func (s *Service) CreateReference(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *CreateReferenceRequest,
|
||||
) (*coredata.TrustCenterReference, error) {
|
||||
) (*coredata.CompliancePortalReference, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
referenceID := gid.New(scope.GetTenantID(), coredata.TrustCenterReferenceEntityType)
|
||||
referenceID := gid.New(scope.GetTenantID(), coredata.CompliancePortalReferenceEntityType)
|
||||
|
||||
var reference *coredata.TrustCenterReference
|
||||
var reference *coredata.CompliancePortalReference
|
||||
|
||||
var logoKey string
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
fileID, s3Key, err := s.uploadReferenceLogoFile(ctx, scope, tx, req.LogoFile, referenceID, req.TrustCenterID, now)
|
||||
fileID, s3Key, err := s.uploadReferenceLogoFile(ctx, scope, tx, req.LogoFile, referenceID, req.CompliancePortalID, now)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot upload logo file: %w", err)
|
||||
}
|
||||
|
||||
logoKey = s3Key
|
||||
|
||||
reference = &coredata.TrustCenterReference{
|
||||
ID: referenceID,
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
TrustCenterID: req.TrustCenterID,
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
WebsiteURL: req.WebsiteURL,
|
||||
LogoFileID: fileID,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
reference = &coredata.CompliancePortalReference{
|
||||
ID: referenceID,
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
CompliancePortalID: req.CompliancePortalID,
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
WebsiteURL: req.WebsiteURL,
|
||||
LogoFileID: fileID,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := reference.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -220,7 +220,7 @@ func (s *Service) UpdateReference(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UpdateReferenceRequest,
|
||||
) (*coredata.TrustCenterReference, error) {
|
||||
) (*coredata.CompliancePortalReference, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -228,7 +228,7 @@ func (s *Service) UpdateReference(
|
||||
now := time.Now()
|
||||
|
||||
var (
|
||||
reference *coredata.TrustCenterReference
|
||||
reference *coredata.CompliancePortalReference
|
||||
newFileID *gid.GID
|
||||
logoKey string
|
||||
)
|
||||
@@ -236,14 +236,14 @@ func (s *Service) UpdateReference(
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
reference = &coredata.TrustCenterReference{}
|
||||
reference = &coredata.CompliancePortalReference{}
|
||||
|
||||
if err := reference.LoadByID(ctx, tx, scope, req.ID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page reference: %w", err)
|
||||
}
|
||||
|
||||
if req.LogoFile != nil {
|
||||
fileID, s3Key, err := s.uploadReferenceLogoFile(ctx, scope, tx, *req.LogoFile, req.ID, reference.TrustCenterID, now)
|
||||
fileID, s3Key, err := s.uploadReferenceLogoFile(ctx, scope, tx, *req.LogoFile, req.ID, reference.CompliancePortalID, now)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot upload logo file: %w", err)
|
||||
}
|
||||
@@ -295,14 +295,14 @@ func (s *Service) UpdateReference(
|
||||
func (s *Service) DeleteReference(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterReferenceID gid.GID,
|
||||
compliancePortalReferenceID gid.GID,
|
||||
) error {
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
reference := &coredata.TrustCenterReference{}
|
||||
reference := &coredata.CompliancePortalReference{}
|
||||
|
||||
if err := reference.LoadByID(ctx, tx, scope, trustCenterReferenceID); err != nil {
|
||||
if err := reference.LoadByID(ctx, tx, scope, compliancePortalReferenceID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page reference: %w", err)
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ func (s *Service) GenerateReferenceLogoURL(
|
||||
scope coredata.Scoper,
|
||||
referenceID gid.GID,
|
||||
) (string, error) {
|
||||
reference := &coredata.TrustCenterReference{}
|
||||
reference := &coredata.CompliancePortalReference{}
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
@@ -358,7 +358,7 @@ func (s *Service) uploadReferenceLogoFile(
|
||||
return gid.GID{}, "", fmt.Errorf("cannot generate object key: %w", err)
|
||||
}
|
||||
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, tx, scope, compliancePageID); err != nil {
|
||||
return gid.GID{}, "", fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user