Fix classification api error

Fix #474

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-10-23 10:56:27 +02:00
parent 9c76a15851
commit d40fa943ce
3 changed files with 20 additions and 0 deletions

View File

@@ -1168,6 +1168,20 @@ func (s *DocumentService) Update(
return fmt.Errorf("cannot update document: %w", err)
}
// Update the draft version if it exists to keep it in sync with the document
draftVersion := &coredata.DocumentVersion{}
err := draftVersion.LoadLatestVersion(ctx, tx, s.svc.scope, req.DocumentID)
if err == nil && draftVersion.Status == coredata.DocumentStatusDraft {
draftVersion.Title = document.Title
draftVersion.OwnerID = document.OwnerID
draftVersion.Classification = document.Classification
draftVersion.UpdatedAt = now
if err := draftVersion.Update(ctx, tx, s.svc.scope); err != nil {
return fmt.Errorf("cannot update draft version: %w", err)
}
}
return nil
},
)

View File

@@ -2547,6 +2547,7 @@ func (r *mutationResolver) CreateDocument(ctx context.Context, input types.Creat
Title: input.Title,
OwnerID: input.OwnerID,
Content: input.Content,
Classification: input.Classification,
TrustCenterVisibility: input.TrustCenterVisibility,
},
)