Decouple users from people
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -35,9 +35,7 @@ type (
|
||||
VersionNumber int `db:"version_number"`
|
||||
Content string `db:"content"`
|
||||
Changelog string `db:"changelog"`
|
||||
CreatedBy gid.GID `db:"created_by"`
|
||||
Status DocumentStatus `db:"status"`
|
||||
PublishedBy *gid.GID `db:"published_by"`
|
||||
PublishedAt *time.Time `db:"published_at"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
@@ -62,9 +60,7 @@ SELECT
|
||||
version_number,
|
||||
content,
|
||||
changelog,
|
||||
created_by,
|
||||
status,
|
||||
published_by,
|
||||
published_at,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -122,9 +118,7 @@ SELECT
|
||||
version_number,
|
||||
content,
|
||||
changelog,
|
||||
created_by,
|
||||
status,
|
||||
published_by,
|
||||
published_at,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -173,7 +167,6 @@ INSERT INTO document_versions (
|
||||
version_number,
|
||||
content,
|
||||
changelog,
|
||||
created_by,
|
||||
status,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -187,7 +180,6 @@ VALUES (
|
||||
@version_number,
|
||||
@content,
|
||||
@changelog,
|
||||
@created_by,
|
||||
@status,
|
||||
@created_at,
|
||||
@updated_at
|
||||
@@ -202,7 +194,6 @@ VALUES (
|
||||
"version_number": p.VersionNumber,
|
||||
"content": p.Content,
|
||||
"changelog": p.Changelog,
|
||||
"created_by": p.CreatedBy,
|
||||
"status": p.Status,
|
||||
"created_at": p.CreatedAt,
|
||||
"updated_at": p.UpdatedAt,
|
||||
@@ -232,9 +223,7 @@ SELECT
|
||||
version_number,
|
||||
content,
|
||||
changelog,
|
||||
created_by,
|
||||
status,
|
||||
published_by,
|
||||
published_at,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -285,9 +274,7 @@ SELECT
|
||||
version_number,
|
||||
content,
|
||||
changelog,
|
||||
created_by,
|
||||
status,
|
||||
published_by,
|
||||
published_at,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -336,9 +323,7 @@ SELECT
|
||||
version_number,
|
||||
content,
|
||||
changelog,
|
||||
created_by,
|
||||
status,
|
||||
published_by,
|
||||
published_at,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -386,7 +371,6 @@ UPDATE document_versions SET
|
||||
changelog = @changelog,
|
||||
status = @status,
|
||||
content = @content,
|
||||
published_by = @published_by,
|
||||
published_at = @published_at,
|
||||
updated_at = @updated_at
|
||||
WHERE %s
|
||||
@@ -402,7 +386,6 @@ WHERE %s
|
||||
"changelog": p.Changelog,
|
||||
"status": p.Status,
|
||||
"content": p.Content,
|
||||
"published_by": p.PublishedBy,
|
||||
"published_at": p.PublishedAt,
|
||||
"updated_at": p.UpdatedAt,
|
||||
}
|
||||
|
||||
6
pkg/coredata/migrations/20250922T120000Z.sql
Normal file
6
pkg/coredata/migrations/20250922T120000Z.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
ALTER TABLE vendor_risk_assessments DROP COLUMN approved_at;
|
||||
ALTER TABLE vendor_risk_assessments DROP COLUMN approved_by;
|
||||
ALTER TABLE vendor_risk_assessments DROP COLUMN assessed_by;
|
||||
ALTER TABLE vendor_risk_assessments DROP COLUMN assessed_at;
|
||||
ALTER TABLE document_versions DROP COLUMN created_by;
|
||||
ALTER TABLE document_versions DROP COLUMN published_by;
|
||||
@@ -31,10 +31,6 @@ type (
|
||||
VendorRiskAssessment struct {
|
||||
ID gid.GID `db:"id"`
|
||||
VendorID gid.GID `db:"vendor_id"`
|
||||
AssessedAt time.Time `db:"assessed_at"`
|
||||
AssessedBy gid.GID `db:"assessed_by"`
|
||||
ApprovedBy *gid.GID `db:"approved_by"`
|
||||
ApprovedAt *time.Time `db:"approved_at"`
|
||||
ExpiresAt time.Time `db:"expires_at"`
|
||||
DataSensitivity DataSensitivity `db:"data_sensitivity"`
|
||||
BusinessImpact BusinessImpact `db:"business_impact"`
|
||||
@@ -54,8 +50,6 @@ func (v VendorRiskAssessment) CursorKey(orderBy VendorRiskAssessmentOrderField)
|
||||
return page.NewCursorKey(v.ID, v.CreatedAt)
|
||||
case VendorRiskAssessmentOrderFieldExpiresAt:
|
||||
return page.NewCursorKey(v.ID, v.ExpiresAt)
|
||||
case VendorRiskAssessmentOrderFieldAssessedAt:
|
||||
return page.NewCursorKey(v.ID, v.AssessedAt)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
|
||||
@@ -73,10 +67,6 @@ INSERT INTO
|
||||
tenant_id,
|
||||
id,
|
||||
vendor_id,
|
||||
assessed_at,
|
||||
assessed_by,
|
||||
approved_by,
|
||||
approved_at,
|
||||
expires_at,
|
||||
data_sensitivity,
|
||||
business_impact,
|
||||
@@ -88,10 +78,6 @@ VALUES (
|
||||
@tenant_id,
|
||||
@id,
|
||||
@vendor_id,
|
||||
@assessed_at,
|
||||
@assessed_by,
|
||||
@approved_by,
|
||||
@approved_at,
|
||||
@expires_at,
|
||||
@data_sensitivity,
|
||||
@business_impact,
|
||||
@@ -105,10 +91,6 @@ VALUES (
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"id": r.ID,
|
||||
"vendor_id": r.VendorID,
|
||||
"assessed_at": r.AssessedAt,
|
||||
"assessed_by": r.AssessedBy,
|
||||
"approved_by": r.ApprovedBy,
|
||||
"approved_at": r.ApprovedAt,
|
||||
"expires_at": r.ExpiresAt,
|
||||
"data_sensitivity": r.DataSensitivity,
|
||||
"business_impact": r.BusinessImpact,
|
||||
@@ -131,10 +113,6 @@ func (r *VendorRiskAssessment) LoadByID(
|
||||
SELECT
|
||||
id,
|
||||
vendor_id,
|
||||
assessed_at,
|
||||
assessed_by,
|
||||
approved_by,
|
||||
approved_at,
|
||||
expires_at,
|
||||
data_sensitivity,
|
||||
business_impact,
|
||||
@@ -183,10 +161,6 @@ func (r *VendorRiskAssessment) LoadLatestByVendorID(
|
||||
SELECT
|
||||
id,
|
||||
vendor_id,
|
||||
assessed_at,
|
||||
assessed_by,
|
||||
approved_by,
|
||||
approved_at,
|
||||
expires_at,
|
||||
data_sensitivity,
|
||||
business_impact,
|
||||
@@ -201,7 +175,7 @@ WHERE
|
||||
%s
|
||||
AND vendor_id = @vendor_id
|
||||
ORDER BY
|
||||
assessed_at DESC
|
||||
created_at DESC
|
||||
LIMIT 1;
|
||||
`
|
||||
|
||||
@@ -238,10 +212,6 @@ func (r *VendorRiskAssessments) LoadByVendorID(
|
||||
SELECT
|
||||
id,
|
||||
vendor_id,
|
||||
assessed_at,
|
||||
assessed_by,
|
||||
approved_by,
|
||||
approved_at,
|
||||
expires_at,
|
||||
data_sensitivity,
|
||||
business_impact,
|
||||
@@ -299,10 +269,6 @@ INSERT INTO vendor_risk_assessments (
|
||||
snapshot_id,
|
||||
source_id,
|
||||
vendor_id,
|
||||
assessed_at,
|
||||
assessed_by,
|
||||
approved_by,
|
||||
approved_at,
|
||||
expires_at,
|
||||
data_sensitivity,
|
||||
business_impact,
|
||||
@@ -316,10 +282,6 @@ SELECT
|
||||
@snapshot_id,
|
||||
vra.id,
|
||||
sv.id,
|
||||
vra.assessed_at,
|
||||
vra.assessed_by,
|
||||
vra.approved_by,
|
||||
vra.approved_at,
|
||||
vra.expires_at,
|
||||
vra.data_sensitivity,
|
||||
vra.business_impact,
|
||||
|
||||
@@ -19,9 +19,8 @@ type (
|
||||
)
|
||||
|
||||
const (
|
||||
VendorRiskAssessmentOrderFieldCreatedAt VendorRiskAssessmentOrderField = "CREATED_AT"
|
||||
VendorRiskAssessmentOrderFieldExpiresAt VendorRiskAssessmentOrderField = "EXPIRES_AT"
|
||||
VendorRiskAssessmentOrderFieldAssessedAt VendorRiskAssessmentOrderField = "ASSESSED_AT"
|
||||
VendorRiskAssessmentOrderFieldCreatedAt VendorRiskAssessmentOrderField = "CREATED_AT"
|
||||
VendorRiskAssessmentOrderFieldExpiresAt VendorRiskAssessmentOrderField = "EXPIRES_AT"
|
||||
)
|
||||
|
||||
func (p VendorRiskAssessmentOrderField) Column() string {
|
||||
|
||||
@@ -69,7 +69,6 @@ type (
|
||||
Approver string
|
||||
Description string
|
||||
PublishedAt *time.Time
|
||||
PublishedBy string
|
||||
Signatures []SignatureData
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
body {
|
||||
font-family: 'Times New Roman', Times, serif;
|
||||
font-size: 11pt;
|
||||
@@ -26,7 +26,7 @@
|
||||
padding: 20px 0;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
|
||||
/* Document container that simulates A4 pages */
|
||||
.document-container {
|
||||
width: 21cm;
|
||||
@@ -34,7 +34,7 @@
|
||||
background: white;
|
||||
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
|
||||
/* Individual page sections */
|
||||
.page-section {
|
||||
padding: 2.5cm;
|
||||
@@ -43,21 +43,21 @@
|
||||
border-bottom: 2px dashed #ddd;
|
||||
page-break-after: always;
|
||||
}
|
||||
|
||||
|
||||
.page-section:last-child {
|
||||
border-bottom: none;
|
||||
page-break-after: auto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.document-header {
|
||||
border-bottom: 1px solid #333;
|
||||
padding-bottom: 15px;
|
||||
margin-bottom: 25px;
|
||||
page-break-after: avoid;
|
||||
}
|
||||
|
||||
|
||||
.document-title {
|
||||
font-size: 18pt;
|
||||
font-weight: bold;
|
||||
@@ -65,7 +65,7 @@
|
||||
margin: 0 0 10px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
.document-meta {
|
||||
background: #f9f9f9;
|
||||
padding: 12px;
|
||||
@@ -73,35 +73,35 @@
|
||||
margin: 15px 0;
|
||||
font-size: 9pt;
|
||||
}
|
||||
|
||||
|
||||
.meta-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
|
||||
.meta-table td {
|
||||
padding: 4px 8px;
|
||||
border-bottom: 1px solid #eee;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
|
||||
.meta-table td:first-child {
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
|
||||
.classification {
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
|
||||
/* Content styling with page break controls */
|
||||
.document-content {
|
||||
orphans: 3;
|
||||
widows: 3;
|
||||
}
|
||||
|
||||
|
||||
.document-content h1 {
|
||||
font-size: 14pt;
|
||||
font-weight: bold;
|
||||
@@ -112,7 +112,7 @@
|
||||
page-break-after: avoid;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
|
||||
.document-content h2 {
|
||||
font-size: 13pt;
|
||||
font-weight: bold;
|
||||
@@ -121,7 +121,7 @@
|
||||
page-break-after: avoid;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
|
||||
.document-content h3 {
|
||||
font-size: 12pt;
|
||||
font-weight: bold;
|
||||
@@ -130,7 +130,7 @@
|
||||
page-break-after: avoid;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
|
||||
.document-content h4 {
|
||||
font-size: 11pt;
|
||||
font-weight: bold;
|
||||
@@ -139,33 +139,33 @@
|
||||
page-break-after: avoid;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
|
||||
.document-content p {
|
||||
margin-bottom: 12px;
|
||||
text-align: justify;
|
||||
orphans: 3;
|
||||
widows: 3;
|
||||
}
|
||||
|
||||
|
||||
.document-content ul,
|
||||
.document-content ol {
|
||||
padding-left: 20px;
|
||||
margin: 12px 0;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
|
||||
.document-content li {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
|
||||
.document-content strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
.document-content em {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
/* Force page breaks at strategic points */
|
||||
.document-content h2:nth-of-type(3),
|
||||
.document-content h2:nth-of-type(5),
|
||||
@@ -173,7 +173,7 @@
|
||||
.document-content h2:nth-of-type(9) {
|
||||
page-break-before: always;
|
||||
}
|
||||
|
||||
|
||||
/* Signatures section */
|
||||
.signatures-section {
|
||||
margin-top: 30px;
|
||||
@@ -182,7 +182,7 @@
|
||||
page-break-before: always;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
|
||||
.signatures-title {
|
||||
font-size: 13pt;
|
||||
font-weight: bold;
|
||||
@@ -190,7 +190,7 @@
|
||||
margin-bottom: 15px;
|
||||
page-break-after: avoid;
|
||||
}
|
||||
|
||||
|
||||
.signatures-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
@@ -198,34 +198,34 @@
|
||||
margin-top: 10px;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
|
||||
.signatures-table th,
|
||||
.signatures-table td {
|
||||
padding: 6px 8px;
|
||||
text-align: left;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
|
||||
.signatures-table th {
|
||||
background: #f5f5f5;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
|
||||
.signatures-table tr {
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
|
||||
.signature-signed {
|
||||
color: #000;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
.signature-requested {
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
.footer {
|
||||
margin-top: 30px;
|
||||
padding-top: 15px;
|
||||
@@ -234,42 +234,42 @@
|
||||
color: #666;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
/* Prevent bad page breaks */
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
page-break-after: avoid;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
|
||||
p, li {
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
|
||||
table, .signatures-section {
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
|
||||
@media print {
|
||||
body {
|
||||
background: white;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
.document-container {
|
||||
box-shadow: none;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
|
||||
.page-section {
|
||||
box-shadow: none;
|
||||
border-bottom: none;
|
||||
padding: 0;
|
||||
min-height: auto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@media screen and (max-width: 21cm) {
|
||||
.document-container {
|
||||
width: 95%;
|
||||
@@ -313,7 +313,7 @@
|
||||
<div class="page-section">
|
||||
<div class="document-header">
|
||||
<h1 class="document-title">{{.Title}}</h1>
|
||||
|
||||
|
||||
<div class="document-meta">
|
||||
<table class="meta-table">
|
||||
<tr>
|
||||
@@ -337,7 +337,7 @@
|
||||
{{- if .PublishedAt}}
|
||||
<tr>
|
||||
<td>Published:</td>
|
||||
<td>{{.PublishedAt.Format "January 2, 2006"}}{{if .PublishedBy}} ({{.PublishedBy}}){{end}}</td>
|
||||
<td>{{.PublishedAt.Format "January 2, 2006"}}</td>
|
||||
</tr>
|
||||
{{- end}}
|
||||
</table>
|
||||
|
||||
@@ -42,7 +42,6 @@ type (
|
||||
Title string
|
||||
Content string
|
||||
OwnerID gid.GID
|
||||
CreatedBy gid.GID
|
||||
DocumentType coredata.DocumentType
|
||||
}
|
||||
|
||||
@@ -186,13 +185,8 @@ func (s *DocumentService) BulkPublishVersions(
|
||||
err := s.svc.pg.WithTx(
|
||||
ctx,
|
||||
func(tx pg.Conn) error {
|
||||
people := &coredata.People{}
|
||||
if err := people.LoadByID(ctx, tx, s.svc.scope, req.PublishedBy); err != nil {
|
||||
return fmt.Errorf("cannot load people: %w", err)
|
||||
}
|
||||
|
||||
for _, documentID := range req.DocumentIDs {
|
||||
document, version, err := s.publishVersionInTx(ctx, tx, documentID, people, &req.Changelog, true)
|
||||
document, version, err := s.publishVersionInTx(ctx, tx, documentID, req.PublishedBy, &req.Changelog, true)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot publish document %q: %w", documentID, err)
|
||||
}
|
||||
@@ -226,12 +220,7 @@ func (s *DocumentService) PublishVersion(
|
||||
func(tx pg.Conn) error {
|
||||
var err error
|
||||
|
||||
people := &coredata.People{}
|
||||
if err := people.LoadByID(ctx, tx, s.svc.scope, publishedBy); err != nil {
|
||||
return fmt.Errorf("cannot load people: %w", err)
|
||||
}
|
||||
|
||||
document, documentVersion, err = s.publishVersionInTx(ctx, tx, documentID, people, changelog, false)
|
||||
document, documentVersion, err = s.publishVersionInTx(ctx, tx, documentID, publishedBy, changelog, false)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot publish version: %w", err)
|
||||
}
|
||||
@@ -251,7 +240,7 @@ func (s *DocumentService) publishVersionInTx(
|
||||
ctx context.Context,
|
||||
tx pg.Conn,
|
||||
documentID gid.GID,
|
||||
publishedBy *coredata.People,
|
||||
publishedBy gid.GID,
|
||||
changelog *string,
|
||||
ignoreExisting bool,
|
||||
) (*coredata.Document, *coredata.DocumentVersion, error) {
|
||||
@@ -296,7 +285,6 @@ func (s *DocumentService) publishVersionInTx(
|
||||
|
||||
documentVersion.Status = coredata.DocumentStatusPublished
|
||||
documentVersion.PublishedAt = &now
|
||||
documentVersion.PublishedBy = &publishedBy.ID
|
||||
documentVersion.UpdatedAt = now
|
||||
|
||||
if err := document.Update(ctx, tx, s.svc.scope); err != nil {
|
||||
@@ -338,7 +326,6 @@ func (s *DocumentService) Create(
|
||||
VersionNumber: 1,
|
||||
Content: req.Content,
|
||||
Status: coredata.DocumentStatusDraft,
|
||||
CreatedBy: req.CreatedBy,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
@@ -745,7 +732,6 @@ func (s *DocumentService) ListSignatures(
|
||||
func (s *DocumentService) CreateDraft(
|
||||
ctx context.Context,
|
||||
documentID gid.GID,
|
||||
createdBy gid.GID,
|
||||
) (*coredata.DocumentVersion, error) {
|
||||
draftVersionID := gid.New(s.svc.scope.GetTenantID(), coredata.DocumentVersionEntityType)
|
||||
|
||||
@@ -776,7 +762,6 @@ func (s *DocumentService) CreateDraft(
|
||||
draftVersion.VersionNumber = latestVersion.VersionNumber + 1
|
||||
draftVersion.Content = latestVersion.Content
|
||||
draftVersion.Status = coredata.DocumentStatusDraft
|
||||
draftVersion.CreatedBy = createdBy
|
||||
draftVersion.CreatedAt = now
|
||||
draftVersion.UpdatedAt = now
|
||||
|
||||
@@ -1314,7 +1299,6 @@ func exportDocumentPDF(
|
||||
document := &coredata.Document{}
|
||||
version := &coredata.DocumentVersion{}
|
||||
owner := &coredata.People{}
|
||||
publishedBy := &coredata.People{}
|
||||
signatures := coredata.DocumentVersionSignatures{}
|
||||
peopleMap := make(map[gid.GID]*coredata.People)
|
||||
|
||||
@@ -1326,12 +1310,6 @@ func exportDocumentPDF(
|
||||
return nil, fmt.Errorf("cannot load document: %w", err)
|
||||
}
|
||||
|
||||
if version.PublishedBy != nil {
|
||||
if err := publishedBy.LoadByID(ctx, conn, scope, *version.PublishedBy); err != nil {
|
||||
return nil, fmt.Errorf("cannot load published by person: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
cursor := page.NewCursor(
|
||||
100,
|
||||
nil,
|
||||
@@ -1385,7 +1363,6 @@ func exportDocumentPDF(
|
||||
Approver: owner.FullName,
|
||||
Description: version.Changelog,
|
||||
PublishedAt: version.PublishedAt,
|
||||
PublishedBy: publishedBy.FullName,
|
||||
Signatures: make([]docgen.SignatureData, len(signatures)),
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,6 @@ type (
|
||||
|
||||
CreateVendorRiskAssessmentRequest struct {
|
||||
VendorID gid.GID
|
||||
AssessedByID gid.GID
|
||||
ExpiresAt time.Time
|
||||
DataSensitivity coredata.DataSensitivity
|
||||
BusinessImpact coredata.BusinessImpact
|
||||
@@ -536,8 +535,6 @@ func (s VendorService) CreateRiskAssessment(
|
||||
vendorRiskAssessment := &coredata.VendorRiskAssessment{
|
||||
ID: vendorRiskAssessmentID,
|
||||
VendorID: req.VendorID,
|
||||
AssessedBy: req.AssessedByID,
|
||||
AssessedAt: now,
|
||||
ExpiresAt: req.ExpiresAt,
|
||||
DataSensitivity: req.DataSensitivity,
|
||||
BusinessImpact: req.BusinessImpact,
|
||||
|
||||
@@ -3187,7 +3187,6 @@ input UpdateDocumentInput {
|
||||
title: String
|
||||
content: String
|
||||
ownerId: ID
|
||||
createdBy: ID
|
||||
documentType: DocumentType
|
||||
showOnTrustCenter: Boolean
|
||||
}
|
||||
@@ -3208,6 +3207,7 @@ input InviteUserInput {
|
||||
organizationId: ID!
|
||||
email: String!
|
||||
fullName: String!
|
||||
createPeople: Boolean!
|
||||
}
|
||||
|
||||
input RemoveUserInput {
|
||||
@@ -3719,8 +3719,6 @@ input VendorRiskAssessmentOrder {
|
||||
type VendorRiskAssessment implements Node {
|
||||
id: ID!
|
||||
vendor: Vendor! @goField(forceResolver: true)
|
||||
assessedAt: Datetime!
|
||||
assessedBy: People! @goField(forceResolver: true)
|
||||
expiresAt: Datetime!
|
||||
dataSensitivity: DataSensitivity!
|
||||
businessImpact: BusinessImpact!
|
||||
@@ -3741,15 +3739,10 @@ enum VendorRiskAssessmentOrderField
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.VendorRiskAssessmentOrderFieldExpiresAt"
|
||||
)
|
||||
ASSESSED_AT
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.VendorRiskAssessmentOrderFieldAssessedAt"
|
||||
)
|
||||
}
|
||||
|
||||
input CreateVendorRiskAssessmentInput {
|
||||
vendorId: ID!
|
||||
assessedBy: ID!
|
||||
expiresAt: Datetime!
|
||||
dataSensitivity: DataSensitivity!
|
||||
businessImpact: BusinessImpact!
|
||||
@@ -3786,7 +3779,6 @@ type DocumentVersion implements Node {
|
||||
orderBy: DocumentVersionSignatureOrder
|
||||
): DocumentVersionSignatureConnection! @goField(forceResolver: true)
|
||||
|
||||
publishedBy: People @goField(forceResolver: true)
|
||||
publishedAt: Datetime
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
|
||||
@@ -574,7 +574,6 @@ type ComplexityRoot struct {
|
||||
ID func(childComplexity int) int
|
||||
Owner func(childComplexity int) int
|
||||
PublishedAt func(childComplexity int) int
|
||||
PublishedBy func(childComplexity int) int
|
||||
Signatures func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DocumentVersionSignatureOrder) int
|
||||
Status func(childComplexity int) int
|
||||
Title func(childComplexity int) int
|
||||
@@ -1422,8 +1421,6 @@ type ComplexityRoot struct {
|
||||
}
|
||||
|
||||
VendorRiskAssessment struct {
|
||||
AssessedAt func(childComplexity int) int
|
||||
AssessedBy func(childComplexity int) int
|
||||
BusinessImpact func(childComplexity int) int
|
||||
CreatedAt func(childComplexity int) int
|
||||
DataSensitivity func(childComplexity int) int
|
||||
@@ -1533,7 +1530,6 @@ type DocumentVersionResolver interface {
|
||||
|
||||
Owner(ctx context.Context, obj *types.DocumentVersion) (*types.People, error)
|
||||
Signatures(ctx context.Context, obj *types.DocumentVersion, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DocumentVersionSignatureOrder) (*types.DocumentVersionSignatureConnection, error)
|
||||
PublishedBy(ctx context.Context, obj *types.DocumentVersion) (*types.People, error)
|
||||
}
|
||||
type DocumentVersionSignatureResolver interface {
|
||||
DocumentVersion(ctx context.Context, obj *types.DocumentVersionSignature) (*types.DocumentVersion, error)
|
||||
@@ -1809,8 +1805,6 @@ type VendorDataPrivacyAgreementResolver interface {
|
||||
}
|
||||
type VendorRiskAssessmentResolver interface {
|
||||
Vendor(ctx context.Context, obj *types.VendorRiskAssessment) (*types.Vendor, error)
|
||||
|
||||
AssessedBy(ctx context.Context, obj *types.VendorRiskAssessment) (*types.People, error)
|
||||
}
|
||||
type VendorServiceResolver interface {
|
||||
Vendor(ctx context.Context, obj *types.VendorService) (*types.Vendor, error)
|
||||
@@ -3297,13 +3291,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.DocumentVersion.PublishedAt(childComplexity), true
|
||||
|
||||
case "DocumentVersion.publishedBy":
|
||||
if e.complexity.DocumentVersion.PublishedBy == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.DocumentVersion.PublishedBy(childComplexity), true
|
||||
|
||||
case "DocumentVersion.signatures":
|
||||
if e.complexity.DocumentVersion.Signatures == nil {
|
||||
break
|
||||
@@ -7710,20 +7697,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.VendorEdge.Node(childComplexity), true
|
||||
|
||||
case "VendorRiskAssessment.assessedAt":
|
||||
if e.complexity.VendorRiskAssessment.AssessedAt == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.VendorRiskAssessment.AssessedAt(childComplexity), true
|
||||
|
||||
case "VendorRiskAssessment.assessedBy":
|
||||
if e.complexity.VendorRiskAssessment.AssessedBy == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.VendorRiskAssessment.AssessedBy(childComplexity), true
|
||||
|
||||
case "VendorRiskAssessment.businessImpact":
|
||||
if e.complexity.VendorRiskAssessment.BusinessImpact == nil {
|
||||
break
|
||||
@@ -11353,7 +11326,6 @@ input UpdateDocumentInput {
|
||||
title: String
|
||||
content: String
|
||||
ownerId: ID
|
||||
createdBy: ID
|
||||
documentType: DocumentType
|
||||
showOnTrustCenter: Boolean
|
||||
}
|
||||
@@ -11374,6 +11346,7 @@ input InviteUserInput {
|
||||
organizationId: ID!
|
||||
email: String!
|
||||
fullName: String!
|
||||
createPeople: Boolean!
|
||||
}
|
||||
|
||||
input RemoveUserInput {
|
||||
@@ -11885,8 +11858,6 @@ input VendorRiskAssessmentOrder {
|
||||
type VendorRiskAssessment implements Node {
|
||||
id: ID!
|
||||
vendor: Vendor! @goField(forceResolver: true)
|
||||
assessedAt: Datetime!
|
||||
assessedBy: People! @goField(forceResolver: true)
|
||||
expiresAt: Datetime!
|
||||
dataSensitivity: DataSensitivity!
|
||||
businessImpact: BusinessImpact!
|
||||
@@ -11907,15 +11878,10 @@ enum VendorRiskAssessmentOrderField
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.VendorRiskAssessmentOrderFieldExpiresAt"
|
||||
)
|
||||
ASSESSED_AT
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.VendorRiskAssessmentOrderFieldAssessedAt"
|
||||
)
|
||||
}
|
||||
|
||||
input CreateVendorRiskAssessmentInput {
|
||||
vendorId: ID!
|
||||
assessedBy: ID!
|
||||
expiresAt: Datetime!
|
||||
dataSensitivity: DataSensitivity!
|
||||
businessImpact: BusinessImpact!
|
||||
@@ -11952,7 +11918,6 @@ type DocumentVersion implements Node {
|
||||
orderBy: DocumentVersionSignatureOrder
|
||||
): DocumentVersionSignatureConnection! @goField(forceResolver: true)
|
||||
|
||||
publishedBy: People @goField(forceResolver: true)
|
||||
publishedAt: Datetime
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
@@ -30012,69 +29977,6 @@ func (ec *executionContext) fieldContext_DocumentVersion_signatures(ctx context.
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _DocumentVersion_publishedBy(ctx context.Context, field graphql.CollectedField, obj *types.DocumentVersion) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_DocumentVersion_publishedBy(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.DocumentVersion().PublishedBy(rctx, obj)
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*types.People)
|
||||
fc.Result = res
|
||||
return ec.marshalOPeople2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPeople(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_DocumentVersion_publishedBy(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "DocumentVersion",
|
||||
Field: field,
|
||||
IsMethod: true,
|
||||
IsResolver: true,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
switch field.Name {
|
||||
case "id":
|
||||
return ec.fieldContext_People_id(ctx, field)
|
||||
case "fullName":
|
||||
return ec.fieldContext_People_fullName(ctx, field)
|
||||
case "primaryEmailAddress":
|
||||
return ec.fieldContext_People_primaryEmailAddress(ctx, field)
|
||||
case "additionalEmailAddresses":
|
||||
return ec.fieldContext_People_additionalEmailAddresses(ctx, field)
|
||||
case "kind":
|
||||
return ec.fieldContext_People_kind(ctx, field)
|
||||
case "position":
|
||||
return ec.fieldContext_People_position(ctx, field)
|
||||
case "contractStartDate":
|
||||
return ec.fieldContext_People_contractStartDate(ctx, field)
|
||||
case "contractEndDate":
|
||||
return ec.fieldContext_People_contractEndDate(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_People_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
return ec.fieldContext_People_updatedAt(ctx, field)
|
||||
}
|
||||
return nil, fmt.Errorf("no field named %q was found under type People", field.Name)
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _DocumentVersion_publishedAt(ctx context.Context, field graphql.CollectedField, obj *types.DocumentVersion) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_DocumentVersion_publishedAt(ctx, field)
|
||||
if err != nil {
|
||||
@@ -30409,8 +30311,6 @@ func (ec *executionContext) fieldContext_DocumentVersionEdge_node(_ context.Cont
|
||||
return ec.fieldContext_DocumentVersion_owner(ctx, field)
|
||||
case "signatures":
|
||||
return ec.fieldContext_DocumentVersion_signatures(ctx, field)
|
||||
case "publishedBy":
|
||||
return ec.fieldContext_DocumentVersion_publishedBy(ctx, field)
|
||||
case "publishedAt":
|
||||
return ec.fieldContext_DocumentVersion_publishedAt(ctx, field)
|
||||
case "createdAt":
|
||||
@@ -30525,8 +30425,6 @@ func (ec *executionContext) fieldContext_DocumentVersionSignature_documentVersio
|
||||
return ec.fieldContext_DocumentVersion_owner(ctx, field)
|
||||
case "signatures":
|
||||
return ec.fieldContext_DocumentVersion_signatures(ctx, field)
|
||||
case "publishedBy":
|
||||
return ec.fieldContext_DocumentVersion_publishedBy(ctx, field)
|
||||
case "publishedAt":
|
||||
return ec.fieldContext_DocumentVersion_publishedAt(ctx, field)
|
||||
case "createdAt":
|
||||
@@ -46514,8 +46412,6 @@ func (ec *executionContext) fieldContext_PublishDocumentVersionPayload_documentV
|
||||
return ec.fieldContext_DocumentVersion_owner(ctx, field)
|
||||
case "signatures":
|
||||
return ec.fieldContext_DocumentVersion_signatures(ctx, field)
|
||||
case "publishedBy":
|
||||
return ec.fieldContext_DocumentVersion_publishedBy(ctx, field)
|
||||
case "publishedAt":
|
||||
return ec.fieldContext_DocumentVersion_publishedAt(ctx, field)
|
||||
case "createdAt":
|
||||
@@ -52026,8 +51922,6 @@ func (ec *executionContext) fieldContext_UpdateDocumentVersionPayload_documentVe
|
||||
return ec.fieldContext_DocumentVersion_owner(ctx, field)
|
||||
case "signatures":
|
||||
return ec.fieldContext_DocumentVersion_signatures(ctx, field)
|
||||
case "publishedBy":
|
||||
return ec.fieldContext_DocumentVersion_publishedBy(ctx, field)
|
||||
case "publishedAt":
|
||||
return ec.fieldContext_DocumentVersion_publishedAt(ctx, field)
|
||||
case "createdAt":
|
||||
@@ -58292,116 +58186,6 @@ func (ec *executionContext) fieldContext_VendorRiskAssessment_vendor(_ context.C
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _VendorRiskAssessment_assessedAt(ctx context.Context, field graphql.CollectedField, obj *types.VendorRiskAssessment) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_VendorRiskAssessment_assessedAt(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.AssessedAt, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(time.Time)
|
||||
fc.Result = res
|
||||
return ec.marshalNDatetime2timeᚐTime(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_VendorRiskAssessment_assessedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "VendorRiskAssessment",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type Datetime does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _VendorRiskAssessment_assessedBy(ctx context.Context, field graphql.CollectedField, obj *types.VendorRiskAssessment) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_VendorRiskAssessment_assessedBy(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.VendorRiskAssessment().AssessedBy(rctx, obj)
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*types.People)
|
||||
fc.Result = res
|
||||
return ec.marshalNPeople2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPeople(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_VendorRiskAssessment_assessedBy(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "VendorRiskAssessment",
|
||||
Field: field,
|
||||
IsMethod: true,
|
||||
IsResolver: true,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
switch field.Name {
|
||||
case "id":
|
||||
return ec.fieldContext_People_id(ctx, field)
|
||||
case "fullName":
|
||||
return ec.fieldContext_People_fullName(ctx, field)
|
||||
case "primaryEmailAddress":
|
||||
return ec.fieldContext_People_primaryEmailAddress(ctx, field)
|
||||
case "additionalEmailAddresses":
|
||||
return ec.fieldContext_People_additionalEmailAddresses(ctx, field)
|
||||
case "kind":
|
||||
return ec.fieldContext_People_kind(ctx, field)
|
||||
case "position":
|
||||
return ec.fieldContext_People_position(ctx, field)
|
||||
case "contractStartDate":
|
||||
return ec.fieldContext_People_contractStartDate(ctx, field)
|
||||
case "contractEndDate":
|
||||
return ec.fieldContext_People_contractEndDate(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_People_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
return ec.fieldContext_People_updatedAt(ctx, field)
|
||||
}
|
||||
return nil, fmt.Errorf("no field named %q was found under type People", field.Name)
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _VendorRiskAssessment_expiresAt(ctx context.Context, field graphql.CollectedField, obj *types.VendorRiskAssessment) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_VendorRiskAssessment_expiresAt(ctx, field)
|
||||
if err != nil {
|
||||
@@ -58854,10 +58638,6 @@ func (ec *executionContext) fieldContext_VendorRiskAssessmentEdge_node(_ context
|
||||
return ec.fieldContext_VendorRiskAssessment_id(ctx, field)
|
||||
case "vendor":
|
||||
return ec.fieldContext_VendorRiskAssessment_vendor(ctx, field)
|
||||
case "assessedAt":
|
||||
return ec.fieldContext_VendorRiskAssessment_assessedAt(ctx, field)
|
||||
case "assessedBy":
|
||||
return ec.fieldContext_VendorRiskAssessment_assessedBy(ctx, field)
|
||||
case "expiresAt":
|
||||
return ec.fieldContext_VendorRiskAssessment_expiresAt(ctx, field)
|
||||
case "dataSensitivity":
|
||||
@@ -63702,7 +63482,7 @@ func (ec *executionContext) unmarshalInputCreateVendorRiskAssessmentInput(ctx co
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"vendorId", "assessedBy", "expiresAt", "dataSensitivity", "businessImpact", "notes"}
|
||||
fieldsInOrder := [...]string{"vendorId", "expiresAt", "dataSensitivity", "businessImpact", "notes"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -63716,13 +63496,6 @@ func (ec *executionContext) unmarshalInputCreateVendorRiskAssessmentInput(ctx co
|
||||
return it, err
|
||||
}
|
||||
it.VendorID = data
|
||||
case "assessedBy":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assessedBy"))
|
||||
data, err := ec.unmarshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.AssessedBy = data
|
||||
case "expiresAt":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("expiresAt"))
|
||||
data, err := ec.unmarshalNDatetime2timeᚐTime(ctx, v)
|
||||
@@ -65261,7 +65034,7 @@ func (ec *executionContext) unmarshalInputInviteUserInput(ctx context.Context, o
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"organizationId", "email", "fullName"}
|
||||
fieldsInOrder := [...]string{"organizationId", "email", "fullName", "createPeople"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -65289,6 +65062,13 @@ func (ec *executionContext) unmarshalInputInviteUserInput(ctx context.Context, o
|
||||
return it, err
|
||||
}
|
||||
it.FullName = data
|
||||
case "createPeople":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createPeople"))
|
||||
data, err := ec.unmarshalNBoolean2bool(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.CreatePeople = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66373,7 +66153,7 @@ func (ec *executionContext) unmarshalInputUpdateDocumentInput(ctx context.Contex
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"id", "title", "content", "ownerId", "createdBy", "documentType", "showOnTrustCenter"}
|
||||
fieldsInOrder := [...]string{"id", "title", "content", "ownerId", "documentType", "showOnTrustCenter"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -66408,13 +66188,6 @@ func (ec *executionContext) unmarshalInputUpdateDocumentInput(ctx context.Contex
|
||||
return it, err
|
||||
}
|
||||
it.OwnerID = data
|
||||
case "createdBy":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdBy"))
|
||||
data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.CreatedBy = data
|
||||
case "documentType":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("documentType"))
|
||||
data, err := ec.unmarshalODocumentType2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐDocumentType(ctx, v)
|
||||
@@ -73483,39 +73256,6 @@ func (ec *executionContext) _DocumentVersion(ctx context.Context, sel ast.Select
|
||||
continue
|
||||
}
|
||||
|
||||
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
||||
case "publishedBy":
|
||||
field := field
|
||||
|
||||
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
}
|
||||
}()
|
||||
res = ec._DocumentVersion_publishedBy(ctx, field, obj)
|
||||
return res
|
||||
}
|
||||
|
||||
if field.Deferrable != nil {
|
||||
dfs, ok := deferred[field.Deferrable.Label]
|
||||
di := 0
|
||||
if ok {
|
||||
dfs.AddField(field)
|
||||
di = len(dfs.Values) - 1
|
||||
} else {
|
||||
dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
|
||||
deferred[field.Deferrable.Label] = dfs
|
||||
}
|
||||
dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
|
||||
return innerFunc(ctx, dfs)
|
||||
})
|
||||
|
||||
// don't run the out.Concurrently() call below
|
||||
out.Values[i] = graphql.Null
|
||||
continue
|
||||
}
|
||||
|
||||
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
||||
case "publishedAt":
|
||||
out.Values[i] = ec._DocumentVersion_publishedAt(ctx, field, obj)
|
||||
@@ -82389,47 +82129,6 @@ func (ec *executionContext) _VendorRiskAssessment(ctx context.Context, sel ast.S
|
||||
continue
|
||||
}
|
||||
|
||||
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
||||
case "assessedAt":
|
||||
out.Values[i] = ec._VendorRiskAssessment_assessedAt(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
case "assessedBy":
|
||||
field := field
|
||||
|
||||
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
}
|
||||
}()
|
||||
res = ec._VendorRiskAssessment_assessedBy(ctx, field, obj)
|
||||
if res == graphql.Null {
|
||||
atomic.AddUint32(&fs.Invalids, 1)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
if field.Deferrable != nil {
|
||||
dfs, ok := deferred[field.Deferrable.Label]
|
||||
di := 0
|
||||
if ok {
|
||||
dfs.AddField(field)
|
||||
di = len(dfs.Values) - 1
|
||||
} else {
|
||||
dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
|
||||
deferred[field.Deferrable.Label] = dfs
|
||||
}
|
||||
dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
|
||||
return innerFunc(ctx, dfs)
|
||||
})
|
||||
|
||||
// don't run the out.Concurrently() call below
|
||||
out.Values[i] = graphql.Null
|
||||
continue
|
||||
}
|
||||
|
||||
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
||||
case "expiresAt":
|
||||
out.Values[i] = ec._VendorRiskAssessment_expiresAt(ctx, field, obj)
|
||||
@@ -90332,14 +90031,12 @@ func (ec *executionContext) marshalNVendorRiskAssessmentOrderField2githubᚗcom
|
||||
|
||||
var (
|
||||
unmarshalNVendorRiskAssessmentOrderField2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐVendorRiskAssessmentOrderField = map[string]coredata.VendorRiskAssessmentOrderField{
|
||||
"CREATED_AT": coredata.VendorRiskAssessmentOrderFieldCreatedAt,
|
||||
"EXPIRES_AT": coredata.VendorRiskAssessmentOrderFieldExpiresAt,
|
||||
"ASSESSED_AT": coredata.VendorRiskAssessmentOrderFieldAssessedAt,
|
||||
"CREATED_AT": coredata.VendorRiskAssessmentOrderFieldCreatedAt,
|
||||
"EXPIRES_AT": coredata.VendorRiskAssessmentOrderFieldExpiresAt,
|
||||
}
|
||||
marshalNVendorRiskAssessmentOrderField2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐVendorRiskAssessmentOrderField = map[coredata.VendorRiskAssessmentOrderField]string{
|
||||
coredata.VendorRiskAssessmentOrderFieldCreatedAt: "CREATED_AT",
|
||||
coredata.VendorRiskAssessmentOrderFieldExpiresAt: "EXPIRES_AT",
|
||||
coredata.VendorRiskAssessmentOrderFieldAssessedAt: "ASSESSED_AT",
|
||||
coredata.VendorRiskAssessmentOrderFieldCreatedAt: "CREATED_AT",
|
||||
coredata.VendorRiskAssessmentOrderFieldExpiresAt: "EXPIRES_AT",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -578,7 +578,6 @@ type CreateVendorPayload struct {
|
||||
|
||||
type CreateVendorRiskAssessmentInput struct {
|
||||
VendorID gid.GID `json:"vendorId"`
|
||||
AssessedBy gid.GID `json:"assessedBy"`
|
||||
ExpiresAt time.Time `json:"expiresAt"`
|
||||
DataSensitivity coredata.DataSensitivity `json:"dataSensitivity"`
|
||||
BusinessImpact coredata.BusinessImpact `json:"businessImpact"`
|
||||
@@ -938,7 +937,6 @@ type DocumentVersion struct {
|
||||
Title string `json:"title"`
|
||||
Owner *People `json:"owner"`
|
||||
Signatures *DocumentVersionSignatureConnection `json:"signatures"`
|
||||
PublishedBy *People `json:"publishedBy,omitempty"`
|
||||
PublishedAt *time.Time `json:"publishedAt,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
@@ -1098,6 +1096,7 @@ type InviteUserInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Email string `json:"email"`
|
||||
FullName string `json:"fullName"`
|
||||
CreatePeople bool `json:"createPeople"`
|
||||
}
|
||||
|
||||
type InviteUserPayload struct {
|
||||
@@ -1590,7 +1589,6 @@ type UpdateDocumentInput struct {
|
||||
Title *string `json:"title,omitempty"`
|
||||
Content *string `json:"content,omitempty"`
|
||||
OwnerID *gid.GID `json:"ownerId,omitempty"`
|
||||
CreatedBy *gid.GID `json:"createdBy,omitempty"`
|
||||
DocumentType *coredata.DocumentType `json:"documentType,omitempty"`
|
||||
ShowOnTrustCenter *bool `json:"showOnTrustCenter,omitempty"`
|
||||
}
|
||||
@@ -2064,8 +2062,6 @@ type VendorFilter struct {
|
||||
type VendorRiskAssessment struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Vendor *Vendor `json:"vendor"`
|
||||
AssessedAt time.Time `json:"assessedAt"`
|
||||
AssessedBy *People `json:"assessedBy"`
|
||||
ExpiresAt time.Time `json:"expiresAt"`
|
||||
DataSensitivity coredata.DataSensitivity `json:"dataSensitivity"`
|
||||
BusinessImpact coredata.BusinessImpact `json:"businessImpact"`
|
||||
|
||||
@@ -46,7 +46,6 @@ func NewVendorRiskAssessmentEdge(c *coredata.VendorRiskAssessment, orderBy cored
|
||||
func NewVendorRiskAssessment(c *coredata.VendorRiskAssessment) *VendorRiskAssessment {
|
||||
return &VendorRiskAssessment{
|
||||
ID: c.ID,
|
||||
AssessedAt: c.AssessedAt,
|
||||
ExpiresAt: c.ExpiresAt,
|
||||
DataSensitivity: c.DataSensitivity,
|
||||
BusinessImpact: c.BusinessImpact,
|
||||
|
||||
@@ -700,27 +700,6 @@ func (r *documentVersionResolver) Signatures(ctx context.Context, obj *types.Doc
|
||||
return types.NewDocumentVersionSignatureConnection(page), nil
|
||||
}
|
||||
|
||||
// PublishedBy is the resolver for the publishedBy field.
|
||||
func (r *documentVersionResolver) PublishedBy(ctx context.Context, obj *types.DocumentVersion) (*types.People, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
documentVersion, err := prb.Documents.GetVersion(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document version: %w", err))
|
||||
}
|
||||
|
||||
if documentVersion.PublishedBy == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
people, err := prb.Peoples.Get(ctx, *documentVersion.PublishedBy)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get people: %w", err))
|
||||
}
|
||||
|
||||
return types.NewPeople(people), nil
|
||||
}
|
||||
|
||||
// DocumentVersion is the resolver for the documentVersion field.
|
||||
func (r *documentVersionSignatureResolver) DocumentVersion(ctx context.Context, obj *types.DocumentVersionSignature) (*types.DocumentVersion, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
@@ -1272,7 +1251,9 @@ func (r *mutationResolver) InviteUser(ctx context.Context, input types.InviteUse
|
||||
|
||||
for _, organization := range organizations {
|
||||
if organization.ID == input.OrganizationID {
|
||||
err := r.usrmgrSvc.InviteUser(ctx, input.OrganizationID, input.FullName, input.Email)
|
||||
createPeople := input.CreatePeople
|
||||
|
||||
err := r.usrmgrSvc.InviteUser(ctx, input.OrganizationID, input.FullName, input.Email, createPeople)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2427,12 +2408,6 @@ func (r *mutationResolver) DeleteVendorDataPrivacyAgreement(ctx context.Context,
|
||||
func (r *mutationResolver) CreateDocument(ctx context.Context, input types.CreateDocumentInput) (*types.CreateDocumentPayload, error) {
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
|
||||
user := UserFromContext(ctx)
|
||||
people, err := prb.Peoples.GetByUserID(ctx, user.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get people: %w", err))
|
||||
}
|
||||
|
||||
document, documentVersion, err := prb.Documents.Create(
|
||||
ctx,
|
||||
probo.CreateDocumentRequest{
|
||||
@@ -2441,7 +2416,6 @@ func (r *mutationResolver) CreateDocument(ctx context.Context, input types.Creat
|
||||
Title: input.Title,
|
||||
OwnerID: input.OwnerID,
|
||||
Content: input.Content,
|
||||
CreatedBy: people.ID,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -2495,12 +2469,7 @@ func (r *mutationResolver) PublishDocumentVersion(ctx context.Context, input typ
|
||||
prb := r.ProboService(ctx, input.DocumentID.TenantID())
|
||||
user := UserFromContext(ctx)
|
||||
|
||||
people, err := prb.Peoples.GetByUserID(ctx, user.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get people: %w", err))
|
||||
}
|
||||
|
||||
document, documentVersion, err := prb.Documents.PublishVersion(ctx, input.DocumentID, people.ID, input.Changelog)
|
||||
document, documentVersion, err := prb.Documents.PublishVersion(ctx, input.DocumentID, user.ID, input.Changelog)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot publish document version: %w", err))
|
||||
}
|
||||
@@ -2524,16 +2493,11 @@ func (r *mutationResolver) BulkPublishDocumentVersions(ctx context.Context, inpu
|
||||
|
||||
user := UserFromContext(ctx)
|
||||
|
||||
people, err := prb.Peoples.GetByUserID(ctx, user.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get people: %w", err))
|
||||
}
|
||||
|
||||
documentVersions, documents, err := prb.Documents.BulkPublishVersions(
|
||||
ctx,
|
||||
probo.BulkPublishVersionsRequest{
|
||||
DocumentIDs: input.DocumentIds,
|
||||
PublishedBy: people.ID,
|
||||
PublishedBy: user.ID,
|
||||
Changelog: input.Changelog,
|
||||
},
|
||||
)
|
||||
@@ -2608,13 +2572,7 @@ func (r *mutationResolver) GenerateDocumentChangelog(ctx context.Context, input
|
||||
func (r *mutationResolver) CreateDraftDocumentVersion(ctx context.Context, input types.CreateDraftDocumentVersionInput) (*types.CreateDraftDocumentVersionPayload, error) {
|
||||
prb := r.ProboService(ctx, input.DocumentID.TenantID())
|
||||
|
||||
user := UserFromContext(ctx)
|
||||
people, err := prb.Peoples.GetByUserID(ctx, user.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get people: %w", err))
|
||||
}
|
||||
|
||||
documentVersion, err := prb.Documents.CreateDraft(ctx, input.DocumentID, people.ID)
|
||||
documentVersion, err := prb.Documents.CreateDraft(ctx, input.DocumentID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot create draft document version: %w", err))
|
||||
}
|
||||
@@ -2767,7 +2725,6 @@ func (r *mutationResolver) CreateVendorRiskAssessment(ctx context.Context, input
|
||||
ctx,
|
||||
probo.CreateVendorRiskAssessmentRequest{
|
||||
VendorID: input.VendorID,
|
||||
AssessedByID: input.AssessedBy,
|
||||
ExpiresAt: input.ExpiresAt,
|
||||
DataSensitivity: input.DataSensitivity,
|
||||
BusinessImpact: input.BusinessImpact,
|
||||
@@ -4601,6 +4558,10 @@ func (r *userResolver) People(ctx context.Context, obj *types.User, organization
|
||||
|
||||
people, err := prb.Peoples.GetByUserID(ctx, obj.ID)
|
||||
if err != nil {
|
||||
var errPeopleNotFound *coredata.ErrPeopleNotFound
|
||||
if errors.As(err, &errPeopleNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
panic(fmt.Errorf("failed to get people: %w", err))
|
||||
}
|
||||
|
||||
@@ -4927,23 +4888,6 @@ func (r *vendorRiskAssessmentResolver) Vendor(ctx context.Context, obj *types.Ve
|
||||
return types.NewVendor(vendor), nil
|
||||
}
|
||||
|
||||
// AssessedBy is the resolver for the assessedBy field.
|
||||
func (r *vendorRiskAssessmentResolver) AssessedBy(ctx context.Context, obj *types.VendorRiskAssessment) (*types.People, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
vendorRiskAssessment, err := prb.Vendors.GetRiskAssessment(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to get vendor risk assessment: %w", err))
|
||||
}
|
||||
|
||||
people, err := prb.Peoples.Get(ctx, vendorRiskAssessment.AssessedBy)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to get assessed by: %w", err))
|
||||
}
|
||||
|
||||
return types.NewPeople(people), nil
|
||||
}
|
||||
|
||||
// Vendor is the resolver for the vendor field.
|
||||
func (r *vendorServiceResolver) Vendor(ctx context.Context, obj *types.VendorService) (*types.Vendor, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
@@ -92,7 +92,6 @@ func (s *DocumentService) ExportPDF(
|
||||
document := &coredata.Document{}
|
||||
version := &coredata.DocumentVersion{}
|
||||
owner := &coredata.People{}
|
||||
publishedBy := &coredata.People{}
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
@@ -109,12 +108,6 @@ func (s *DocumentService) ExportPDF(
|
||||
return fmt.Errorf("cannot load latest published document version: %w", err)
|
||||
}
|
||||
|
||||
if version.PublishedBy != nil {
|
||||
if err := publishedBy.LoadByID(ctx, conn, s.svc.scope, *version.PublishedBy); err != nil {
|
||||
return fmt.Errorf("cannot load published by person: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, document.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load document owner: %w", err)
|
||||
}
|
||||
@@ -143,7 +136,6 @@ func (s *DocumentService) ExportPDF(
|
||||
Approver: owner.FullName,
|
||||
Description: version.Changelog,
|
||||
PublishedAt: version.PublishedAt,
|
||||
PublishedBy: publishedBy.FullName,
|
||||
}
|
||||
|
||||
htmlContent, err := docgen.RenderHTML(docData)
|
||||
|
||||
@@ -84,6 +84,7 @@ type (
|
||||
OrganizationID gid.GID `json:"organization_id"`
|
||||
Email string `json:"email"`
|
||||
FullName string `json:"full_name"`
|
||||
CreatePeople bool `json:"create_people"`
|
||||
}
|
||||
|
||||
PasswordResetData struct {
|
||||
@@ -661,6 +662,7 @@ func (s Service) InviteUser(
|
||||
organizationID gid.GID,
|
||||
fullName string,
|
||||
emailAddress string,
|
||||
createPeople bool,
|
||||
) error {
|
||||
if _, err := mail.ParseAddress(emailAddress); err != nil {
|
||||
return &ErrInvalidEmail{emailAddress}
|
||||
@@ -697,32 +699,40 @@ func (s Service) InviteUser(
|
||||
return fmt.Errorf("cannot insert user organization: %w", err)
|
||||
}
|
||||
|
||||
people := &coredata.People{}
|
||||
scope := coredata.NewScope(organizationID.TenantID())
|
||||
if err := people.LoadByEmail(ctx, tx, scope, emailAddress); err != nil {
|
||||
var errPeopleNotFound *coredata.ErrPeopleNotFound
|
||||
if createPeople {
|
||||
people := &coredata.People{}
|
||||
scope := coredata.NewScope(organizationID.TenantID())
|
||||
if err := people.LoadByEmail(ctx, tx, scope, emailAddress); err != nil {
|
||||
var errPeopleNotFound *coredata.ErrPeopleNotFound
|
||||
|
||||
if errors.As(err, &errPeopleNotFound) {
|
||||
people = &coredata.People{
|
||||
ID: gid.New(organizationID.TenantID(), coredata.PeopleEntityType),
|
||||
OrganizationID: organizationID,
|
||||
UserID: &user.ID,
|
||||
FullName: fullName,
|
||||
PrimaryEmailAddress: emailAddress,
|
||||
Kind: coredata.PeopleKindContractor,
|
||||
AdditionalEmailAddresses: []string{},
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
if errors.As(err, &errPeopleNotFound) {
|
||||
people = &coredata.People{
|
||||
ID: gid.New(organizationID.TenantID(), coredata.PeopleEntityType),
|
||||
OrganizationID: organizationID,
|
||||
UserID: &user.ID,
|
||||
FullName: fullName,
|
||||
PrimaryEmailAddress: emailAddress,
|
||||
Kind: coredata.PeopleKindContractor,
|
||||
AdditionalEmailAddresses: []string{},
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
}
|
||||
|
||||
if err := people.Insert(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot insert people: %w", err)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("cannot load people by email: %w", err)
|
||||
}
|
||||
} else {
|
||||
people.UserID = &user.ID
|
||||
people.FullName = fullName
|
||||
people.UpdatedAt = time.Now()
|
||||
|
||||
if err := people.Insert(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot insert people: %w", err)
|
||||
if err := people.Update(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot update people: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot load people by email: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -741,7 +751,7 @@ func (s Service) InviteUser(
|
||||
s.tokenSecret,
|
||||
TokenTypeOrganizationInvitation,
|
||||
s.invitationTokenValidity,
|
||||
InvitationData{OrganizationID: organizationID, Email: emailAddress, FullName: fullName},
|
||||
InvitationData{OrganizationID: organizationID, Email: emailAddress, FullName: fullName, CreatePeople: createPeople},
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot generate confirmation token: %w", err)
|
||||
@@ -832,39 +842,41 @@ func (s Service) ConfirmInvitation(ctx context.Context, tokenString string, pass
|
||||
return fmt.Errorf("cannot insert user organization: %w", err)
|
||||
}
|
||||
|
||||
people := &coredata.People{}
|
||||
scope := coredata.NewScope(token.Data.OrganizationID.TenantID())
|
||||
if token.Data.CreatePeople {
|
||||
people := &coredata.People{}
|
||||
scope := coredata.NewScope(token.Data.OrganizationID.TenantID())
|
||||
|
||||
if err := people.LoadByEmail(ctx, tx, scope, token.Data.Email); err != nil {
|
||||
var errPeopleNotFound *coredata.ErrPeopleNotFound
|
||||
if err := people.LoadByEmail(ctx, tx, scope, token.Data.Email); err != nil {
|
||||
var errPeopleNotFound *coredata.ErrPeopleNotFound
|
||||
|
||||
if errors.As(err, &errPeopleNotFound) {
|
||||
peopleID := gid.New(token.Data.OrganizationID.TenantID(), coredata.PeopleEntityType)
|
||||
people = &coredata.People{
|
||||
ID: peopleID,
|
||||
OrganizationID: token.Data.OrganizationID,
|
||||
UserID: &user.ID,
|
||||
FullName: token.Data.FullName,
|
||||
PrimaryEmailAddress: token.Data.Email,
|
||||
Kind: coredata.PeopleKindEmployee,
|
||||
AdditionalEmailAddresses: []string{},
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
if errors.As(err, &errPeopleNotFound) {
|
||||
peopleID := gid.New(token.Data.OrganizationID.TenantID(), coredata.PeopleEntityType)
|
||||
people = &coredata.People{
|
||||
ID: peopleID,
|
||||
OrganizationID: token.Data.OrganizationID,
|
||||
UserID: &user.ID,
|
||||
FullName: token.Data.FullName,
|
||||
PrimaryEmailAddress: token.Data.Email,
|
||||
Kind: coredata.PeopleKindEmployee,
|
||||
AdditionalEmailAddresses: []string{},
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := people.Insert(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot insert people: %w", err)
|
||||
if err := people.Insert(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot insert people: %w", err)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("cannot load people by email: %w", err)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("cannot load people by email: %w", err)
|
||||
}
|
||||
} else {
|
||||
people.UserID = &user.ID
|
||||
people.FullName = token.Data.FullName
|
||||
people.UpdatedAt = now
|
||||
people.UserID = &user.ID
|
||||
people.FullName = token.Data.FullName
|
||||
people.UpdatedAt = now
|
||||
|
||||
if err := people.Update(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot update people: %w", err)
|
||||
if err := people.Update(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot update people: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user