@@ -45,7 +45,6 @@ func (s AuditService) Get(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -70,7 +69,6 @@ func (s AuditService) GetByReportID(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -89,6 +87,7 @@ func (s AuditService) ListForOrganizationId(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
filter := coredata.NewAuditTrustCenterFilter()
|
||||
|
||||
err := audits.LoadByOrganizationID(ctx, conn, s.svc.scope, organizationID, cursor, filter)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load audits: %w", err)
|
||||
@@ -97,7 +96,6 @@ func (s AuditService) ListForOrganizationId(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ func (s ComplianceExternalURLService) ListForTrustCenterID(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ func (s ComplianceFrameworkService) ListByTrustCenterID(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ var complianceTmpl = template.Must(
|
||||
s = strings.ReplaceAll(s, `|`, `\|`)
|
||||
s = strings.ReplaceAll(s, "\n", " ")
|
||||
s = strings.ReplaceAll(s, "\r", "")
|
||||
|
||||
return s
|
||||
},
|
||||
}).
|
||||
@@ -136,9 +137,11 @@ func (s *Service) RenderCompliancePageMarkdown(
|
||||
if org.WebsiteURL != nil && *org.WebsiteURL != "" {
|
||||
data.Details = append(data.Details, compliancePageDetail{Label: "Website", Value: *org.WebsiteURL})
|
||||
}
|
||||
|
||||
if org.Email != nil && *org.Email != "" {
|
||||
data.Details = append(data.Details, compliancePageDetail{Label: "Email", Value: *org.Email})
|
||||
}
|
||||
|
||||
if org.HeadquarterAddress != nil && *org.HeadquarterAddress != "" {
|
||||
data.Details = append(data.Details, compliancePageDetail{Label: "Headquarters", Value: *org.HeadquarterAddress})
|
||||
}
|
||||
@@ -264,6 +267,7 @@ func (s *Service) fetchDocumentIDs(ctx context.Context, tenantSvc *TenantService
|
||||
if doc.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
|
||||
continue
|
||||
}
|
||||
|
||||
ids = append(ids, doc.ID.String())
|
||||
}
|
||||
|
||||
@@ -313,6 +317,7 @@ func (s *Service) fetchComplianceFrameworks(ctx context.Context, tenantSvc *Tena
|
||||
if fw.Description != nil {
|
||||
fi.Description = *fw.Description
|
||||
}
|
||||
|
||||
frameworks = append(frameworks, fi)
|
||||
}
|
||||
|
||||
@@ -352,6 +357,7 @@ func (s *Service) fetchDocuments(ctx context.Context, tenantSvc *TenantService,
|
||||
if doc.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
|
||||
continue
|
||||
}
|
||||
|
||||
docs = append(
|
||||
docs,
|
||||
compliancePageDocument{
|
||||
@@ -399,6 +405,7 @@ func (s *Service) fetchAudits(ctx context.Context, tenantSvc *TenantService, org
|
||||
}
|
||||
|
||||
frameworkName := ""
|
||||
|
||||
fw, err := tenantSvc.Frameworks.Get(ctx, audit.FrameworkID)
|
||||
if err == nil {
|
||||
frameworkName = fw.Name
|
||||
@@ -411,9 +418,11 @@ func (s *Service) fetchAudits(ctx context.Context, tenantSvc *TenantService, org
|
||||
if audit.ValidFrom != nil {
|
||||
ai.ValidFrom = audit.ValidFrom.Format("2006-01-02")
|
||||
}
|
||||
|
||||
if audit.ValidUntil != nil {
|
||||
ai.ValidUntil = audit.ValidUntil.Format("2006-01-02")
|
||||
}
|
||||
|
||||
audits = append(audits, ai)
|
||||
}
|
||||
|
||||
@@ -506,6 +515,7 @@ func (s *Service) fetchReferences(ctx context.Context, tenantSvc *TenantService,
|
||||
if r.Description != nil {
|
||||
ri.Description = *r.Description
|
||||
}
|
||||
|
||||
refs = append(refs, ri)
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ func (s *DocumentService) ListForOrganizationId(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -118,7 +117,6 @@ func (s DocumentService) Get(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -172,7 +170,6 @@ func (s *DocumentService) exportPDFData(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -204,6 +201,7 @@ func (s *DocumentService) generatePDFOnTheFly(
|
||||
version *coredata.DocumentVersion,
|
||||
) ([]byte, error) {
|
||||
organization := &coredata.Organization{}
|
||||
|
||||
var approverNames []string
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
@@ -216,6 +214,7 @@ func (s *DocumentService) generatePDFOnTheFly(
|
||||
}
|
||||
} else if lastQuorum.Status == coredata.DocumentVersionApprovalQuorumStatusApproved {
|
||||
approvedDecisions := &coredata.DocumentVersionApprovalDecisions{}
|
||||
|
||||
approvedFilter := coredata.NewDocumentVersionApprovalDecisionFilter(
|
||||
coredata.DocumentVersionApprovalDecisionStates{coredata.DocumentVersionApprovalDecisionStateApproved},
|
||||
)
|
||||
@@ -262,12 +261,12 @@ func (s *DocumentService) generatePDFOnTheFly(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
classification := docgen.ClassificationSecret
|
||||
|
||||
switch version.Classification {
|
||||
case coredata.DocumentClassificationPublic:
|
||||
classification = docgen.ClassificationPublic
|
||||
@@ -278,8 +277,10 @@ func (s *DocumentService) generatePDFOnTheFly(
|
||||
}
|
||||
|
||||
horizontalLogoBase64 := ""
|
||||
|
||||
if organization.HorizontalLogoFileID != nil {
|
||||
fileRecord := &coredata.File{}
|
||||
|
||||
fileErr := s.svc.pg.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
||||
return fileRecord.LoadByID(ctx, conn, s.svc.scope, *organization.HorizontalLogoFileID)
|
||||
})
|
||||
|
||||
@@ -43,7 +43,6 @@ func (s FrameworkService) Get(
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ func (s OrganizationService) Get(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -86,7 +85,6 @@ func (s OrganizationService) GetOrganizationCustomDomain(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -109,6 +107,7 @@ func (s OrganizationService) GenerateLogoURL(
|
||||
}
|
||||
|
||||
file := &coredata.File{}
|
||||
|
||||
err = s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
|
||||
@@ -66,7 +66,6 @@ func (s ReportService) loadByID(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -143,6 +142,7 @@ func (s ReportService) exportPDFData(
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot download PDF from S3: %w", err)
|
||||
}
|
||||
|
||||
defer func() { _ = result.Body.Close() }()
|
||||
|
||||
pdfData, err := io.ReadAll(result.Body)
|
||||
|
||||
@@ -152,13 +152,13 @@ func (s *Service) Get(
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return ErrPageNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot load trust center: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -180,13 +180,13 @@ func (s *Service) GetBySlug(
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return ErrPageNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot load trust center: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -230,7 +230,6 @@ func (s *Service) GetByDomainName(ctx context.Context, domain string) (*coredata
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -263,13 +262,16 @@ func (s *Service) GetCustomDomainByOrganizationID(ctx context.Context, organizat
|
||||
// esign certificate worker which needs per-org branding at render time.
|
||||
func (s *Service) EmailPresenterConfigByOrganizationID(ctx context.Context, orgID gid.GID) (emails.PresenterConfig, error) {
|
||||
var trustCenter coredata.TrustCenter
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(orgID)
|
||||
|
||||
err := s.pg.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
||||
return trustCenter.LoadByOrganizationID(ctx, conn, scope, orgID)
|
||||
})
|
||||
if err != nil {
|
||||
return emails.PresenterConfig{}, fmt.Errorf("cannot load trust center for org %s: %w", orgID, err)
|
||||
}
|
||||
|
||||
return s.WithTenant(orgID.TenantID()).TrustCenters.EmailPresenterConfig(ctx, trustCenter.ID)
|
||||
}
|
||||
|
||||
@@ -404,8 +406,10 @@ func (s *Service) ProvisionMember(
|
||||
}
|
||||
|
||||
var sig *coredata.ElectronicSignature
|
||||
|
||||
if compliancePage.NonDisclosureAgreementFileID != nil && s.esign != nil {
|
||||
var err error
|
||||
|
||||
sig, err = s.esign.CreateSignature(
|
||||
ctx,
|
||||
tx,
|
||||
|
||||
@@ -45,7 +45,6 @@ func (s ThirdPartyService) Get(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -74,7 +73,6 @@ func (s ThirdPartyService) ListForOrganizationId(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -99,6 +97,7 @@ func (s ThirdPartyService) CountForTrustCenterId(
|
||||
thirdParties := &coredata.ThirdParties{}
|
||||
showOnTrustCenter := true
|
||||
filter := coredata.NewThirdPartyFilter(&showOnTrustCenter)
|
||||
|
||||
count, err = thirdParties.CountByOrganizationID(ctx, conn, s.svc.scope, trustCenter.OrganizationID, filter)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot count thirdParties: %w", err)
|
||||
@@ -107,7 +106,6 @@ func (s ThirdPartyService) CountForTrustCenterId(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ func (s TrustCenterAccessService) Request(
|
||||
documentIDs := req.DocumentIDs
|
||||
if req.DocumentIDs == nil {
|
||||
var allDocuments coredata.Documents
|
||||
|
||||
filter := coredata.NewDocumentTrustCenterFilter()
|
||||
|
||||
if err := allDocuments.LoadAllByOrganizationID(ctx, tx, s.svc.scope, organizationID, filter); err != nil {
|
||||
@@ -90,6 +91,7 @@ func (s TrustCenterAccessService) Request(
|
||||
reportIDs := req.ReportIDs
|
||||
if req.ReportIDs == nil {
|
||||
var allAudits coredata.Audits
|
||||
|
||||
auditFilter := coredata.NewAuditTrustCenterFilter()
|
||||
|
||||
if err := allAudits.LoadAllByOrganizationID(ctx, tx, s.svc.scope, organizationID, auditFilter); err != nil {
|
||||
@@ -106,6 +108,7 @@ func (s TrustCenterAccessService) Request(
|
||||
trustCenterFileIDs := req.TrustCenterFileIDs
|
||||
if req.TrustCenterFileIDs == nil {
|
||||
var allTrustCenterFiles coredata.TrustCenterFiles
|
||||
|
||||
filter := coredata.NewTrustCenterFileFilter(
|
||||
coredata.WithTrustCenterFileVisibilities(coredata.TrustCenterVisibilityPrivate, coredata.TrustCenterVisibilityNone),
|
||||
)
|
||||
@@ -173,7 +176,6 @@ func (s TrustCenterAccessService) Request(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -209,6 +211,7 @@ func (s TrustCenterAccessService) GetDocumentAccess(
|
||||
|
||||
err := s.svc.pg.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
||||
access := &coredata.TrustCenterAccess{}
|
||||
|
||||
err := access.LoadByTrustCenterIDAndIdentityID(ctx, conn, s.svc.scope, trustCenterID, identityID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
@@ -230,6 +233,7 @@ func (s TrustCenterAccessService) GetDocumentAccess(
|
||||
}
|
||||
|
||||
documentAccess = &coredata.TrustCenterDocumentAccess{}
|
||||
|
||||
err = documentAccess.LoadByTrustCenterAccessIDAndDocumentID(ctx, conn, s.svc.scope, access.ID, documentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
@@ -241,7 +245,6 @@ func (s TrustCenterAccessService) GetDocumentAccess(
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -259,6 +262,7 @@ func (s TrustCenterAccessService) GetReportAccess(
|
||||
|
||||
err := s.svc.pg.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
||||
access := &coredata.TrustCenterAccess{}
|
||||
|
||||
err := access.LoadByTrustCenterIDAndIdentityID(ctx, conn, s.svc.scope, trustCenterID, identityID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
@@ -280,6 +284,7 @@ func (s TrustCenterAccessService) GetReportAccess(
|
||||
}
|
||||
|
||||
reportAccess = &coredata.TrustCenterDocumentAccess{}
|
||||
|
||||
err = reportAccess.LoadByTrustCenterAccessIDAndReportID(ctx, conn, s.svc.scope, access.ID, reportID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
@@ -291,7 +296,6 @@ func (s TrustCenterAccessService) GetReportAccess(
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -309,6 +313,7 @@ func (s TrustCenterAccessService) GetTrustCenterFileAccess(
|
||||
|
||||
err := s.svc.pg.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
||||
access := &coredata.TrustCenterAccess{}
|
||||
|
||||
err := access.LoadByTrustCenterIDAndIdentityID(ctx, conn, s.svc.scope, trustCenterID, identityID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
@@ -330,6 +335,7 @@ func (s TrustCenterAccessService) GetTrustCenterFileAccess(
|
||||
}
|
||||
|
||||
fileAccess = &coredata.TrustCenterDocumentAccess{}
|
||||
|
||||
err = fileAccess.LoadByTrustCenterAccessIDAndTrustCenterFileID(ctx, conn, s.svc.scope, access.ID, trustCenterFileID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
@@ -341,7 +347,6 @@ func (s TrustCenterAccessService) GetTrustCenterFileAccess(
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -392,11 +397,13 @@ func (s *TrustCenterAccessService) GrantByIDs(
|
||||
return fmt.Errorf("cannot grant document accesses: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(reportIDs) > 0 {
|
||||
if err := coredata.GrantByReportIDs(ctx, tx, s.svc.scope, access.ID, reportIDs, now); err != nil {
|
||||
return fmt.Errorf("cannot grant report accesses: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(fileIDs) > 0 {
|
||||
if err := coredata.GrantByTrustCenterFileIDs(ctx, tx, s.svc.scope, access.ID, fileIDs, now); err != nil {
|
||||
return fmt.Errorf("cannot grant trust center file accesses: %w", err)
|
||||
@@ -405,6 +412,7 @@ func (s *TrustCenterAccessService) GrantByIDs(
|
||||
|
||||
if shouldSendEmail {
|
||||
profile.State = coredata.ProfileStateActive
|
||||
|
||||
profile.UpdatedAt = now
|
||||
if err := profile.Update(ctx, tx, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot update profile: %w", err)
|
||||
@@ -458,6 +466,7 @@ func (s *TrustCenterAccessService) sendAccessEmail(ctx context.Context, tx pg.Tx
|
||||
if err := accessEmail.Insert(ctx, tx); err != nil {
|
||||
return fmt.Errorf("cannot insert access email: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -495,18 +504,23 @@ func (s *TrustCenterAccessService) RejectOrRevokeByIDs(
|
||||
|
||||
if len(documentIDs) > 0 {
|
||||
shouldSendEmail = true
|
||||
|
||||
if err := coredata.RejectOrRevokeByDocumentIDs(ctx, tx, s.svc.scope, access.ID, documentIDs, now); err != nil {
|
||||
return fmt.Errorf("cannot reject/revoke document accesses: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(reportIDs) > 0 {
|
||||
shouldSendEmail = true
|
||||
|
||||
if err := coredata.RejectOrRevokeByReportIDs(ctx, tx, s.svc.scope, access.ID, reportIDs, now); err != nil {
|
||||
return fmt.Errorf("cannot reject/revoke report accesses: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(fileIDs) > 0 {
|
||||
shouldSendEmail = true
|
||||
|
||||
if err := coredata.RejectOrRevokeByTrustCenterFileIDs(ctx, tx, s.svc.scope, access.ID, fileIDs, now); err != nil {
|
||||
return fmt.Errorf("cannot reject/revoke trust center file accesses: %w", err)
|
||||
}
|
||||
@@ -536,30 +550,38 @@ func (s *TrustCenterAccessService) sendDocumentAccessRejectedEmail(
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
var fileNames []string
|
||||
var documents coredata.Documents
|
||||
var (
|
||||
fileNames []string
|
||||
documents coredata.Documents
|
||||
)
|
||||
|
||||
if len(documentIDs) > 0 {
|
||||
if err := documents.LoadByIDs(ctx, tx, s.svc.scope, documentIDs); err != nil {
|
||||
return fmt.Errorf("cannot load documents by IDs: %w", err)
|
||||
}
|
||||
|
||||
for _, d := range documents {
|
||||
fileNames = append(fileNames, d.Title)
|
||||
}
|
||||
}
|
||||
|
||||
var reports coredata.Reports
|
||||
if len(reportIDs) > 0 {
|
||||
if err := reports.LoadByIDs(ctx, tx, s.svc.scope, reportIDs); err != nil {
|
||||
return fmt.Errorf("cannot load reports by IDs: %w", err)
|
||||
}
|
||||
|
||||
for _, r := range reports {
|
||||
fileNames = append(fileNames, r.Filename)
|
||||
}
|
||||
}
|
||||
|
||||
var files coredata.TrustCenterFiles
|
||||
if len(fileIDs) > 0 {
|
||||
if err := files.LoadByIDs(ctx, tx, s.svc.scope, fileIDs); err != nil {
|
||||
return fmt.Errorf("cannot load files by IDs: %w", err)
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
fileNames = append(fileNames, f.Name)
|
||||
}
|
||||
@@ -595,21 +617,26 @@ func (s *TrustCenterAccessService) sendDocumentAccessRejectedEmail(
|
||||
if err := accessEmail.Insert(ctx, tx); err != nil {
|
||||
return fmt.Errorf("cannot insert access email: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func extractExistingIDs(accesses coredata.TrustCenterDocumentAccesses) ([]gid.GID, []gid.GID, []gid.GID) {
|
||||
var documentIDs []gid.GID
|
||||
var reportIDs []gid.GID
|
||||
var trustCenterFileIDs []gid.GID
|
||||
var (
|
||||
documentIDs []gid.GID
|
||||
reportIDs []gid.GID
|
||||
trustCenterFileIDs []gid.GID
|
||||
)
|
||||
|
||||
for _, access := range accesses {
|
||||
if access.DocumentID != nil {
|
||||
documentIDs = append(documentIDs, *access.DocumentID)
|
||||
}
|
||||
|
||||
if access.ReportID != nil {
|
||||
reportIDs = append(reportIDs, *access.ReportID)
|
||||
}
|
||||
|
||||
if access.TrustCenterFileID != nil {
|
||||
trustCenterFileIDs = append(trustCenterFileIDs, *access.TrustCenterFileID)
|
||||
}
|
||||
@@ -625,6 +652,7 @@ func filterExistingIDs(allIDs []gid.GID, existingIDs []gid.GID) []gid.GID {
|
||||
}
|
||||
|
||||
var newIDs []gid.GID
|
||||
|
||||
for _, id := range allIDs {
|
||||
if !existingMap[id] {
|
||||
newIDs = append(newIDs, id)
|
||||
|
||||
@@ -50,7 +50,6 @@ func (s *TrustCenterFileService) Get(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -85,7 +84,6 @@ func (s *TrustCenterFileService) ListForOrganizationId(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -108,6 +106,7 @@ func (s *TrustCenterFileService) ExportFile(
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("cannot add watermark to PDF: %w", err)
|
||||
}
|
||||
|
||||
return watermarkedPDF, mimeType, nil
|
||||
}
|
||||
|
||||
@@ -125,8 +124,10 @@ func (s *TrustCenterFileService) exportFileData(
|
||||
ctx context.Context,
|
||||
trustCenterFileID gid.GID,
|
||||
) ([]byte, string, error) {
|
||||
var trustCenterFile *coredata.TrustCenterFile
|
||||
var file *coredata.File
|
||||
var (
|
||||
trustCenterFile *coredata.TrustCenterFile
|
||||
file *coredata.File
|
||||
)
|
||||
|
||||
err := s.svc.pg.WithConn(ctx, func(ctx context.Context, conn pg.Querier) error {
|
||||
trustCenterFile = &coredata.TrustCenterFile{}
|
||||
@@ -152,6 +153,7 @@ func (s *TrustCenterFileService) exportFileData(
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("cannot download file from S3: %w", err)
|
||||
}
|
||||
|
||||
defer func() { _ = result.Body.Close() }()
|
||||
|
||||
fileData, err := io.ReadAll(result.Body)
|
||||
|
||||
@@ -46,7 +46,6 @@ func (s TrustCenterReferenceService) ListForTrustCenterID(
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -61,6 +60,7 @@ func (s TrustCenterReferenceService) GenerateLogoURL(
|
||||
) (string, error) {
|
||||
reference := &coredata.TrustCenterReference{}
|
||||
file := &coredata.File{}
|
||||
|
||||
err := s.svc.pg.WithTx(ctx, func(ctx context.Context, tx pg.Tx) error {
|
||||
err := reference.LoadByID(ctx, tx, s.svc.scope, referenceID)
|
||||
if err != nil {
|
||||
@@ -74,7 +74,6 @@ func (s TrustCenterReferenceService) GenerateLogoURL(
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return "", nil
|
||||
}
|
||||
@@ -117,7 +116,6 @@ func (s TrustCenterReferenceService) Get(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -48,7 +48,6 @@ func (s TrustCenterService) Get(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot load trust center: %w", err)
|
||||
}
|
||||
@@ -73,7 +72,6 @@ func (s TrustCenterService) GetByOrganizationID(
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user