Adopt File type for trust logos and MCP
Trust GraphQL and MCP still exposed presigned URL strings for trust-center logos while console and connect already serve stable File.downloadUrl paths. Phase 1 migrates the seven public logo fields on trust GraphQL and the trust-center file references on MCP to the shared File type; trust GraphQL NDA stays on fileUrl for a follow-up. Trust resolvers load public files through filemanager and map them with types.NewFile. The trust app Relay queries and components now read logo.downloadUrl. MCP specification, resolvers, and helpers are updated in sync, including NDA on MCP where callers already have file access. filemanager is split into focused files and its URL surface is narrowed to GenerateFileURL(file) for stable app URLs and GeneratePresignedURL for S3 redirects. GetPublicFile remains the DB entry point when only a file ID is known. Add trust and MCP e2e coverage for public logo download URLs. Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
@@ -90,7 +90,7 @@ func (r *auditResolver) ReportFile(ctx context.Context, obj *types.Audit) (*type
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewFile(file, r.baseURL), nil
|
||||
return types.NewFile(file, r.fileManager), nil
|
||||
}
|
||||
|
||||
// Controls is the resolver for the controls field.
|
||||
|
||||
@@ -43,7 +43,7 @@ func (r *evidenceResolver) File(ctx context.Context, obj *types.Evidence) (*type
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewFile(file, r.baseURL), nil
|
||||
return types.NewFile(file, r.fileManager), nil
|
||||
}
|
||||
|
||||
// Task is the resolver for the task field.
|
||||
|
||||
@@ -40,5 +40,5 @@ func (r *Resolver) loadFile(ctx context.Context, fileID gid.GID) (*types.File, e
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewFile(file, r.baseURL), nil
|
||||
return types.NewFile(file, r.fileManager), nil
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"go.probo.inc/probo/pkg/connector/provider"
|
||||
"go.probo.inc/probo/pkg/cookiebanner"
|
||||
"go.probo.inc/probo/pkg/esign"
|
||||
"go.probo.inc/probo/pkg/filemanager"
|
||||
"go.probo.inc/probo/pkg/iam"
|
||||
"go.probo.inc/probo/pkg/mailman"
|
||||
"go.probo.inc/probo/pkg/probo"
|
||||
@@ -50,6 +51,7 @@ func NewGraphQLHandler(
|
||||
logger *log.Logger,
|
||||
thirdPartySvc *thirdparty.Service,
|
||||
riskManagementSvc *riskmanagement.Service,
|
||||
fileManagerSvc *filemanager.Service,
|
||||
baseURL *baseurl.BaseURL,
|
||||
) http.Handler {
|
||||
config := schema.Config{
|
||||
@@ -68,6 +70,7 @@ func NewGraphQLHandler(
|
||||
riskManagement: riskManagementSvc,
|
||||
thirdParty: thirdPartySvc,
|
||||
customDomainCname: customDomainCname,
|
||||
fileManager: fileManagerSvc,
|
||||
baseURL: baseURL,
|
||||
logger: logger,
|
||||
},
|
||||
|
||||
@@ -34,6 +34,7 @@ import (
|
||||
"go.probo.inc/probo/pkg/cookiebanner"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/esign"
|
||||
"go.probo.inc/probo/pkg/filemanager"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/iam"
|
||||
"go.probo.inc/probo/pkg/mailman"
|
||||
@@ -64,6 +65,7 @@ type (
|
||||
riskManagement *riskmanagement.Service
|
||||
thirdParty *thirdparty.Service
|
||||
logger *log.Logger
|
||||
fileManager *filemanager.Service
|
||||
baseURL *baseurl.BaseURL
|
||||
customDomainCname string
|
||||
}
|
||||
@@ -82,6 +84,7 @@ func NewMux(
|
||||
tokenSecret string,
|
||||
connectorRegistry *connector.ConnectorRegistry,
|
||||
providerRegistry *provider.Registry,
|
||||
fileManagerSvc *filemanager.Service,
|
||||
baseURL *baseurl.BaseURL,
|
||||
customDomainCname string,
|
||||
thirdPartySvc *thirdparty.Service,
|
||||
@@ -105,6 +108,7 @@ func NewMux(
|
||||
logger,
|
||||
thirdPartySvc,
|
||||
riskManagementSvc,
|
||||
fileManagerSvc,
|
||||
baseURL,
|
||||
)
|
||||
|
||||
|
||||
@@ -1086,7 +1086,7 @@ func (r *thirdPartyComplianceReportResolver) File(ctx context.Context, obj *type
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewFile(file, r.baseURL), nil
|
||||
return types.NewFile(file, r.fileManager), nil
|
||||
}
|
||||
|
||||
// Permission is the resolver for the permission field.
|
||||
|
||||
@@ -1064,7 +1064,7 @@ func (r *trustCenterDocumentAccessResolver) ReportFile(ctx context.Context, obj
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewFile(file, r.baseURL), nil
|
||||
return types.NewFile(file, r.fileManager), nil
|
||||
}
|
||||
|
||||
// Audit is the resolver for the audit field.
|
||||
|
||||
@@ -15,20 +15,17 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"go.probo.inc/probo/pkg/baseurl"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/filemanager"
|
||||
)
|
||||
|
||||
func NewFile(r *coredata.File, base *baseurl.BaseURL) *File {
|
||||
url := base.WithPath(filemanager.DownloadAPIPath(r)).MustString()
|
||||
|
||||
func NewFile(r *coredata.File, files *filemanager.Service) *File {
|
||||
return &File{
|
||||
ID: r.ID,
|
||||
MimeType: r.MimeType,
|
||||
FileName: r.FileName,
|
||||
Size: r.FileSize,
|
||||
DownloadURL: url,
|
||||
DownloadURL: files.GenerateFileURL(r),
|
||||
CreatedAt: r.CreatedAt,
|
||||
UpdatedAt: r.UpdatedAt,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user