Remove unused visitor portal helpers
Brand and public file serving replaced the old org/portal logo and report URL generators, leaving dead methods and unused Service fields behind. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -30,7 +30,6 @@ var (
|
|||||||
ErrUserNotFound = errors.New("user not found")
|
ErrUserNotFound = errors.New("user not found")
|
||||||
ErrUserInactive = errors.New("user inactive")
|
ErrUserInactive = errors.New("user inactive")
|
||||||
ErrDocumentAccessNotFound = errors.New("document access not found")
|
ErrDocumentAccessNotFound = errors.New("document access not found")
|
||||||
ErrNDAFileNotFound = errors.New("NDA file not found")
|
|
||||||
ErrDocumentNotFound = errors.New("document not found")
|
ErrDocumentNotFound = errors.New("document not found")
|
||||||
ErrDocumentNotVisible = errors.New("document not visible")
|
ErrDocumentNotVisible = errors.New("document not visible")
|
||||||
ErrReportNotFound = errors.New("report not found")
|
ErrReportNotFound = errors.New("report not found")
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ package visitor
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.gearno.de/kit/pg"
|
"go.gearno.de/kit/pg"
|
||||||
"go.probo.inc/probo/pkg/coredata"
|
"go.probo.inc/probo/pkg/coredata"
|
||||||
@@ -54,89 +53,3 @@ func (s *Service) GetFramework(
|
|||||||
|
|
||||||
return framework, nil
|
return framework, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) GenerateFrameworkLightLogoURL(
|
|
||||||
ctx context.Context,
|
|
||||||
scope coredata.Scoper,
|
|
||||||
frameworkID gid.GID,
|
|
||||||
expiresIn time.Duration,
|
|
||||||
) (*string, error) {
|
|
||||||
file := &coredata.File{}
|
|
||||||
|
|
||||||
err := s.pg.WithConn(
|
|
||||||
ctx,
|
|
||||||
func(ctx context.Context, conn pg.Querier) error {
|
|
||||||
framework := &coredata.Framework{}
|
|
||||||
if err := framework.LoadByID(ctx, conn, scope, frameworkID); err != nil {
|
|
||||||
return fmt.Errorf("cannot load framework: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if framework.LightLogoFileID == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := file.LoadByID(ctx, conn, scope, *framework.LightLogoFileID); err != nil {
|
|
||||||
return fmt.Errorf("cannot load file: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if file.FileKey == "" {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
presignedURL, err := s.fileManager.GeneratePresignedURL(ctx, file, expiresIn)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("cannot generate file URL: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &presignedURL, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) GenerateFrameworkDarkLogoURL(
|
|
||||||
ctx context.Context,
|
|
||||||
scope coredata.Scoper,
|
|
||||||
frameworkID gid.GID,
|
|
||||||
expiresIn time.Duration,
|
|
||||||
) (*string, error) {
|
|
||||||
file := &coredata.File{}
|
|
||||||
|
|
||||||
err := s.pg.WithConn(
|
|
||||||
ctx,
|
|
||||||
func(ctx context.Context, conn pg.Querier) error {
|
|
||||||
framework := &coredata.Framework{}
|
|
||||||
if err := framework.LoadByID(ctx, conn, scope, frameworkID); err != nil {
|
|
||||||
return fmt.Errorf("cannot load framework: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if framework.DarkLogoFileID == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := file.LoadByID(ctx, conn, scope, *framework.DarkLogoFileID); err != nil {
|
|
||||||
return fmt.Errorf("cannot load file: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if file.FileKey == "" {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
presignedURL, err := s.fileManager.GeneratePresignedURL(ctx, file, expiresIn)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("cannot generate file URL: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &presignedURL, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,114 +0,0 @@
|
|||||||
// Copyright (c) 2025-2026 Probo Inc <hello@probo.com>.
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
|
|
||||||
package visitor
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"net/url"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
|
||||||
"go.gearno.de/kit/pg"
|
|
||||||
"go.probo.inc/probo/pkg/coredata"
|
|
||||||
"go.probo.inc/probo/pkg/gid"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (s *Service) GetOrganization(
|
|
||||||
ctx context.Context,
|
|
||||||
scope coredata.Scoper,
|
|
||||||
organizationID gid.GID,
|
|
||||||
) (*coredata.Organization, error) {
|
|
||||||
organization := &coredata.Organization{}
|
|
||||||
|
|
||||||
err := s.pg.WithConn(
|
|
||||||
ctx,
|
|
||||||
func(ctx context.Context, conn pg.Querier) error {
|
|
||||||
err := organization.LoadByID(
|
|
||||||
ctx,
|
|
||||||
conn,
|
|
||||||
scope,
|
|
||||||
organizationID,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("cannot load organization: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return organization, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) GenerateOrganizationLogoURL(
|
|
||||||
ctx context.Context,
|
|
||||||
scope coredata.Scoper,
|
|
||||||
organizationID gid.GID,
|
|
||||||
expiresIn time.Duration,
|
|
||||||
) (*string, error) {
|
|
||||||
organization, err := s.GetOrganization(ctx, scope, organizationID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("cannot get organization: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if organization.LogoFileID == nil {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
file := &coredata.File{}
|
|
||||||
|
|
||||||
err = s.pg.WithConn(
|
|
||||||
ctx,
|
|
||||||
func(ctx context.Context, conn pg.Querier) error {
|
|
||||||
return file.LoadByID(ctx, conn, scope, *organization.LogoFileID)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("cannot load file: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
presignClient := s3.NewPresignClient(s.s3)
|
|
||||||
|
|
||||||
encodedFilename := url.QueryEscape(file.FileName)
|
|
||||||
contentDisposition := fmt.Sprintf("attachment; filename=\"%s\"; filename*=UTF-8''%s",
|
|
||||||
encodedFilename, encodedFilename)
|
|
||||||
|
|
||||||
presignedReq, err := presignClient.PresignGetObject(
|
|
||||||
ctx,
|
|
||||||
&s3.GetObjectInput{
|
|
||||||
Bucket: new(s.bucket),
|
|
||||||
Key: new(file.FileKey),
|
|
||||||
ResponseCacheControl: new("max-age=3600, public"),
|
|
||||||
ResponseContentDisposition: new(contentDisposition),
|
|
||||||
}, func(opts *s3.PresignOptions) {
|
|
||||||
opts.Expires = expiresIn
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("cannot presign GetObject request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &presignedReq.URL, nil
|
|
||||||
}
|
|
||||||
@@ -58,31 +58,6 @@ func (s *Service) ListPortalReferencesForPortalID(
|
|||||||
return page.NewPage(references, cursor), nil
|
return page.NewPage(references, cursor), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) GeneratePortalReferenceLogoURL(
|
|
||||||
ctx context.Context,
|
|
||||||
scope coredata.Scoper,
|
|
||||||
referenceID gid.GID,
|
|
||||||
) (string, error) {
|
|
||||||
reference := &coredata.TrustCenterReference{}
|
|
||||||
|
|
||||||
err := s.pg.WithTx(
|
|
||||||
ctx,
|
|
||||||
func(ctx context.Context, tx pg.Tx) error {
|
|
||||||
return reference.LoadByID(ctx, tx, scope, referenceID)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("cannot load compliance page reference: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
file, err := s.fileManager.GetPublicFile(ctx, reference.LogoFileID)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.fileManager.GenerateFileURL(file), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) GetPortalReference(
|
func (s *Service) GetPortalReference(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
scope coredata.Scoper,
|
scope coredata.Scoper,
|
||||||
|
|||||||
@@ -57,31 +57,6 @@ func (s *Service) GetPortal(
|
|||||||
return compliancePage, nil
|
return compliancePage, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) GetPortalByOrganizationID(
|
|
||||||
ctx context.Context,
|
|
||||||
scope coredata.Scoper,
|
|
||||||
organizationID gid.GID,
|
|
||||||
) (*coredata.TrustCenter, error) {
|
|
||||||
compliancePage := &coredata.TrustCenter{}
|
|
||||||
|
|
||||||
err := s.pg.WithConn(
|
|
||||||
ctx,
|
|
||||||
func(ctx context.Context, conn pg.Querier) error {
|
|
||||||
err := compliancePage.LoadByOrganizationID(ctx, conn, scope, organizationID)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return compliancePage, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) GetPortalNDAFile(
|
func (s *Service) GetPortalNDAFile(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
scope coredata.Scoper,
|
scope coredata.Scoper,
|
||||||
@@ -156,100 +131,6 @@ func (s *Service) GeneratePortalNDAFileURL(
|
|||||||
return presignedURL, nil
|
return presignedURL, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) GeneratePortalLogoURL(
|
|
||||||
ctx context.Context,
|
|
||||||
scope coredata.Scoper,
|
|
||||||
compliancePageID gid.GID,
|
|
||||||
expiresIn time.Duration,
|
|
||||||
) (*string, error) {
|
|
||||||
file := &coredata.File{}
|
|
||||||
compliancePage := &coredata.TrustCenter{}
|
|
||||||
|
|
||||||
err := s.pg.WithConn(
|
|
||||||
ctx,
|
|
||||||
func(ctx context.Context, conn pg.Querier) error {
|
|
||||||
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
|
|
||||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if compliancePage.LogoFileID == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := file.LoadByID(ctx, conn, scope, *compliancePage.LogoFileID); err != nil {
|
|
||||||
return fmt.Errorf("cannot load file: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if compliancePage.LogoFileID == nil {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if file.FileKey == "" {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
presignedURL, err := s.fileManager.GeneratePresignedURL(ctx, file, expiresIn)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("cannot generate file URL: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &presignedURL, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) GeneratePortalDarkLogoURL(
|
|
||||||
ctx context.Context,
|
|
||||||
scope coredata.Scoper,
|
|
||||||
compliancePageID gid.GID,
|
|
||||||
expiresIn time.Duration,
|
|
||||||
) (*string, error) {
|
|
||||||
file := &coredata.File{}
|
|
||||||
compliancePage := &coredata.TrustCenter{}
|
|
||||||
|
|
||||||
err := s.pg.WithConn(
|
|
||||||
ctx,
|
|
||||||
func(ctx context.Context, conn pg.Querier) error {
|
|
||||||
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
|
|
||||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if compliancePage.DarkLogoFileID == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := file.LoadByID(ctx, conn, scope, *compliancePage.DarkLogoFileID); err != nil {
|
|
||||||
return fmt.Errorf("cannot load file: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if compliancePage.DarkLogoFileID == nil {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if file.FileKey == "" {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
presignedURL, err := s.fileManager.GeneratePresignedURL(ctx, file, expiresIn)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("cannot generate file URL: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &presignedURL, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) GetPortalEmailPresenterConfig(
|
func (s *Service) GetPortalEmailPresenterConfig(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
scope coredata.Scoper,
|
scope coredata.Scoper,
|
||||||
@@ -321,37 +202,3 @@ func (s *Service) GetPortalEmailPresenterConfig(
|
|||||||
|
|
||||||
return emailPresenterCfg, nil
|
return emailPresenterCfg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) GetPortalMailingList(
|
|
||||||
ctx context.Context,
|
|
||||||
scope coredata.Scoper,
|
|
||||||
compliancePageID gid.GID,
|
|
||||||
) (*coredata.MailingList, error) {
|
|
||||||
var mailingList *coredata.MailingList
|
|
||||||
|
|
||||||
err := s.pg.WithConn(
|
|
||||||
ctx,
|
|
||||||
func(ctx context.Context, conn pg.Querier) error {
|
|
||||||
compliancePage := &coredata.TrustCenter{}
|
|
||||||
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
|
|
||||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if compliancePage.MailingListID == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
mailingList = &coredata.MailingList{}
|
|
||||||
if err := mailingList.LoadByID(ctx, conn, scope, *compliancePage.MailingListID); err != nil {
|
|
||||||
return fmt.Errorf("cannot load mailing list: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return mailingList, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||||
"go.gearno.de/kit/pg"
|
"go.gearno.de/kit/pg"
|
||||||
@@ -88,38 +87,6 @@ func (s *Service) loadReportByID(
|
|||||||
return file, nil
|
return file, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) GenerateReportDownloadURL(
|
|
||||||
ctx context.Context,
|
|
||||||
scope coredata.Scoper,
|
|
||||||
fileID gid.GID,
|
|
||||||
expiresIn time.Duration,
|
|
||||||
) (*string, error) {
|
|
||||||
file, err := s.loadReportByID(ctx, scope, fileID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("cannot get file: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
presignClient := s3.NewPresignClient(s.s3)
|
|
||||||
|
|
||||||
presignedReq, err := presignClient.PresignGetObject(
|
|
||||||
ctx,
|
|
||||||
&s3.GetObjectInput{
|
|
||||||
Bucket: new(s.bucket),
|
|
||||||
Key: new(file.FileKey),
|
|
||||||
ResponseCacheControl: new("max-age=3600, public"),
|
|
||||||
ResponseContentType: new(file.MimeType),
|
|
||||||
ResponseContentDisposition: new(fmt.Sprintf("attachment; filename=\"%s\"", file.FileName)),
|
|
||||||
}, func(opts *s3.PresignOptions) {
|
|
||||||
opts.Expires = expiresIn
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("cannot presign GetObject request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &presignedReq.URL, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) ExportReportPDF(
|
func (s *Service) ExportReportPDF(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
scope coredata.Scoper,
|
scope coredata.Scoper,
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import (
|
|||||||
"go.probo.inc/probo/pkg/filemanager"
|
"go.probo.inc/probo/pkg/filemanager"
|
||||||
"go.probo.inc/probo/pkg/gid"
|
"go.probo.inc/probo/pkg/gid"
|
||||||
"go.probo.inc/probo/pkg/html2pdf"
|
"go.probo.inc/probo/pkg/html2pdf"
|
||||||
"go.probo.inc/probo/pkg/iam"
|
|
||||||
"go.probo.inc/probo/pkg/resourcealias"
|
"go.probo.inc/probo/pkg/resourcealias"
|
||||||
"go.probo.inc/probo/pkg/slack"
|
"go.probo.inc/probo/pkg/slack"
|
||||||
)
|
)
|
||||||
@@ -48,20 +47,17 @@ type (
|
|||||||
// public read operations for the compliance page and its related resources as
|
// public read operations for the compliance page and its related resources as
|
||||||
// methods on a single type.
|
// methods on a single type.
|
||||||
Service struct {
|
Service struct {
|
||||||
pg *pg.Client
|
pg *pg.Client
|
||||||
s3 *s3.Client
|
s3 *s3.Client
|
||||||
bucket string
|
bucket string
|
||||||
slackSigningSecret string
|
baseURL string
|
||||||
baseURL string
|
esign *esign.Service
|
||||||
baseDomain string
|
html2pdfConverter *html2pdf.Converter
|
||||||
iam *iam.Service
|
fileManager *filemanager.Service
|
||||||
esign *esign.Service
|
logger *log.Logger
|
||||||
html2pdfConverter *html2pdf.Converter
|
slack *slack.Service
|
||||||
fileManager *filemanager.Service
|
resourceAlias *resourcealias.Service
|
||||||
logger *log.Logger
|
management *management.Service
|
||||||
slack *slack.Service
|
|
||||||
resourceAlias *resourcealias.Service
|
|
||||||
management *management.Service
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -70,9 +66,6 @@ func NewService(
|
|||||||
s3Client *s3.Client,
|
s3Client *s3.Client,
|
||||||
bucket string,
|
bucket string,
|
||||||
baseURL string,
|
baseURL string,
|
||||||
baseDomain string,
|
|
||||||
slackSigningSecret string,
|
|
||||||
iam *iam.Service,
|
|
||||||
esignSvc *esign.Service,
|
esignSvc *esign.Service,
|
||||||
html2pdfConverter *html2pdf.Converter,
|
html2pdfConverter *html2pdf.Converter,
|
||||||
fileManagerService *filemanager.Service,
|
fileManagerService *filemanager.Service,
|
||||||
@@ -82,20 +75,17 @@ func NewService(
|
|||||||
managementSvc *management.Service,
|
managementSvc *management.Service,
|
||||||
) *Service {
|
) *Service {
|
||||||
svc := &Service{
|
svc := &Service{
|
||||||
pg: pgClient,
|
pg: pgClient,
|
||||||
s3: s3Client,
|
s3: s3Client,
|
||||||
bucket: bucket,
|
bucket: bucket,
|
||||||
slackSigningSecret: slackSigningSecret,
|
baseURL: baseURL,
|
||||||
baseURL: baseURL,
|
esign: esignSvc,
|
||||||
baseDomain: baseDomain,
|
html2pdfConverter: html2pdfConverter,
|
||||||
iam: iam,
|
fileManager: fileManagerService,
|
||||||
esign: esignSvc,
|
logger: logger,
|
||||||
html2pdfConverter: html2pdfConverter,
|
slack: slack,
|
||||||
fileManager: fileManagerService,
|
resourceAlias: resourceAliasSvc,
|
||||||
logger: logger,
|
management: managementSvc,
|
||||||
slack: slack,
|
|
||||||
resourceAlias: resourceAliasSvc,
|
|
||||||
management: managementSvc,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return svc
|
return svc
|
||||||
@@ -129,34 +119,6 @@ func (s *Service) GetPortalByID(
|
|||||||
return compliancePage, nil
|
return compliancePage, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) GetPortalBySlug(
|
|
||||||
ctx context.Context,
|
|
||||||
slug string,
|
|
||||||
) (*coredata.TrustCenter, error) {
|
|
||||||
compliancePage := &coredata.TrustCenter{}
|
|
||||||
|
|
||||||
err := s.pg.WithConn(
|
|
||||||
ctx,
|
|
||||||
func(ctx context.Context, conn pg.Querier) error {
|
|
||||||
err := compliancePage.LoadBySlug(ctx, conn, slug)
|
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
|
||||||
return ErrPageNotFound
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return compliancePage, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetEffectiveCanonicalHost returns the host a compliance page should be
|
// GetEffectiveCanonicalHost returns the host a compliance page should be
|
||||||
// served under. It prefers the primary domain when its certificate is active,
|
// served under. It prefers the primary domain when its certificate is active,
|
||||||
// and otherwise falls back to the managed probopage subdomain. An empty string
|
// and otherwise falls back to the managed probopage subdomain. An empty string
|
||||||
@@ -296,46 +258,6 @@ func (s *Service) GetPortalMembership(ctx context.Context, compliancePageID gid.
|
|||||||
return membership, nil
|
return membership, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) GetPortalNDAFileByID(
|
|
||||||
ctx context.Context,
|
|
||||||
compliancePageID gid.GID,
|
|
||||||
) (*coredata.File, error) {
|
|
||||||
var (
|
|
||||||
file *coredata.File
|
|
||||||
scope = coredata.NewScopeFromObjectID(compliancePageID)
|
|
||||||
)
|
|
||||||
|
|
||||||
err := s.pg.WithConn(
|
|
||||||
ctx,
|
|
||||||
func(ctx context.Context, conn pg.Querier) error {
|
|
||||||
compliancePage := &coredata.TrustCenter{}
|
|
||||||
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
|
|
||||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if compliancePage.NonDisclosureAgreementFileID == nil {
|
|
||||||
return ErrNDAFileNotFound
|
|
||||||
}
|
|
||||||
|
|
||||||
file = &coredata.File{}
|
|
||||||
if err := file.LoadByID(ctx, conn, scope, *compliancePage.NonDisclosureAgreementFileID); err != nil {
|
|
||||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
|
||||||
return ErrNDAFileNotFound
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Errorf("cannot load file: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return file, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) ProvisionPortalMember(
|
func (s *Service) ProvisionPortalMember(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
compliancePageID gid.GID,
|
compliancePageID gid.GID,
|
||||||
|
|||||||
@@ -676,9 +676,6 @@ func (impl *Implm) Run(
|
|||||||
s3Client,
|
s3Client,
|
||||||
impl.cfg.AWS.Bucket,
|
impl.cfg.AWS.Bucket,
|
||||||
baseURL.String(),
|
baseURL.String(),
|
||||||
impl.cfg.TrustCenter.BaseDomain,
|
|
||||||
impl.cfg.GetSlackSigningSecret(),
|
|
||||||
iamService,
|
|
||||||
esignService,
|
esignService,
|
||||||
html2pdfConverter,
|
html2pdfConverter,
|
||||||
fileManagerService,
|
fileManagerService,
|
||||||
|
|||||||
Reference in New Issue
Block a user