Sanitize upon saving

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-03-30 17:52:25 +04:00
parent 62e68dfb6f
commit f3982f23f9
23 changed files with 471 additions and 356 deletions

View File

@@ -1,17 +1,3 @@
// Copyright (c) 2025-2026 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package connect_v1
// This file will be automatically regenerated based on the schema, any resolver

View File

@@ -3766,7 +3766,6 @@ type Mutation {
updateDocument(input: UpdateDocumentInput!): UpdateDocumentPayload!
archiveDocument(input: ArchiveDocumentInput!): ArchiveDocumentPayload!
unarchiveDocument(input: UnarchiveDocumentInput!): UnarchiveDocumentPayload!
updateDocumentVersionContent(input: UpdateDocumentVersionContentInput!): UpdateDocumentVersionContentPayload!
deleteDocument(input: DeleteDocumentInput!): DeleteDocumentPayload!
# Meeting mutations
createMeeting(input: CreateMeetingInput!): CreateMeetingPayload!
@@ -4486,11 +4485,6 @@ input UpdateDocumentInput {
trustCenterVisibility: TrustCenterVisibility
}
input UpdateDocumentVersionContentInput {
id: ID!
content: String!
}
input ExportDocumentVersionPDFInput {
documentVersionId: ID!
withWatermark: Boolean!
@@ -5256,10 +5250,6 @@ type UnarchiveDocumentPayload {
document: Document!
}
type UpdateDocumentVersionContentPayload {
content: String!
}
type DeleteDocumentPayload {
deletedDocumentId: ID!
}

View File

@@ -4734,38 +4734,6 @@ func (r *mutationResolver) UnarchiveDocument(ctx context.Context, input types.Un
}, nil
}
// UpdateDocumentVersionContent is the resolver for the updateDocumentVersionContent field.
func (r *mutationResolver) UpdateDocumentVersionContent(ctx context.Context, input types.UpdateDocumentVersionContentInput) (*types.UpdateDocumentVersionContentPayload, error) {
if err := r.authorize(ctx, input.ID, probo.ActionDocumentUpdate); err != nil {
return nil, err
}
prb := r.ProboService(ctx, input.ID.TenantID())
content, err := prb.Documents.UpdateDocumentVersionContent(
ctx,
probo.UpdateDocumentVersionRequest{
ID: input.ID,
Content: input.Content,
},
)
if err != nil {
if _, ok := errors.AsType[*probo.ErrDocumentVersionNotDraft](err); ok {
return nil, gqlutils.Conflict(ctx, err)
}
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
}
r.logger.ErrorCtx(ctx, "cannot update document version content", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return &types.UpdateDocumentVersionContentPayload{
Content: content,
}, nil
}
// DeleteDocument is the resolver for the deleteDocument field.
func (r *mutationResolver) DeleteDocument(ctx context.Context, input types.DeleteDocumentInput) (*types.DeleteDocumentPayload, error) {
if err := r.authorize(ctx, input.DocumentID, probo.ActionDocumentDelete); err != nil {

View File

@@ -3351,29 +3351,3 @@ func (r *Resolver) PublishMinorDocumentVersionTool(ctx context.Context, req *mcp
DocumentVersion: types.NewDocumentVersion(documentVersion),
}, nil
}
func (r *Resolver) UpdateDocumentVersionContentTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateDocumentVersionContentInput) (*mcp.CallToolResult, types.UpdateDocumentVersionContentOutput, error) {
r.MustAuthorize(ctx, input.DocumentVersionID, probo.ActionDocumentUpdate)
svc := r.ProboService(ctx, input.DocumentVersionID)
content, err := svc.Documents.UpdateDocumentVersionContent(
ctx,
probo.UpdateDocumentVersionRequest{
ID: input.DocumentVersionID,
Content: input.Content,
},
)
if err != nil {
var errNotDraft *probo.ErrDocumentVersionNotDraft
if errors.As(err, &errNotDraft) {
return nil, types.UpdateDocumentVersionContentOutput{}, fmt.Errorf("cannot update document version content: %w", err)
}
panic(fmt.Errorf("cannot update document version content: %w", err))
}
return nil, types.UpdateDocumentVersionContentOutput{
Content: content,
}, nil
}

View File

@@ -5597,28 +5597,6 @@ components:
document_version:
$ref: "#/components/schemas/DocumentVersion"
UpdateDocumentVersionContentInput:
type: object
required:
- document_version_id
- content
properties:
document_version_id:
$ref: "#/components/schemas/GID"
description: Document version ID
content:
type: string
description: ProseMirror JSON document content
UpdateDocumentVersionContentOutput:
type: object
required:
- content
properties:
content:
type: string
description: Updated document content
DeleteDraftDocumentVersionInput:
type: object
required:
@@ -7506,14 +7484,6 @@ tools:
$ref: "#/components/schemas/UpdateDocumentVersionInput"
outputSchema:
$ref: "#/components/schemas/UpdateDocumentVersionOutput"
- name: updateDocumentVersionContent
description: Update draft document version body content only (ProseMirror JSON).
hints:
readonly: false
inputSchema:
$ref: "#/components/schemas/UpdateDocumentVersionContentInput"
outputSchema:
$ref: "#/components/schemas/UpdateDocumentVersionContentOutput"
- name: deleteDraftDocumentVersion
description: Delete a draft document version
hints:

View File

@@ -1,17 +1,3 @@
// Copyright (c) 2025-2026 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package trust_v1
// This file will be automatically regenerated based on the schema, any resolver