1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-10 18:10:49 +09:00

GO-4969: Restrict markdown export to actual objects, don't call for media etc.

This commit is contained in:
Jannis Metrikat 2025-05-06 19:23:16 +02:00
parent 1ac71bb151
commit 40cf8e2eaf
No known key found for this signature in database
GPG key ID: B223CAC5AAF85615
2 changed files with 10 additions and 7 deletions

View file

@ -124,7 +124,7 @@ func (s *Service) GetObject(ctx context.Context, spaceId string, objectId string
return apimodel.ObjectWithBody{}, err
}
markdown, err := s.getMarkdownExport(ctx, spaceId, objectId)
markdown, err := s.getMarkdownExport(ctx, spaceId, objectId, model.ObjectTypeLayout(resp.ObjectView.Details[0].Details.Fields[bundle.RelationKeyResolvedLayout.String()].GetNumberValue()))
if err != nil {
return apimodel.ObjectWithBody{}, err
}
@ -435,12 +435,15 @@ func (s *Service) GetObjectWithBlocksFromStruct(details *types.Struct, markdown
}
// getMarkdownExport retrieves the Markdown export of an object.
func (s *Service) getMarkdownExport(ctx context.Context, spaceId string, objectId string) (string, error) {
md, err := s.exportService.ExportSingleInMemory(ctx, spaceId, objectId, model.Export_Markdown)
if err != nil {
return "", ErrFailedExportMarkdown
func (s *Service) getMarkdownExport(ctx context.Context, spaceId string, objectId string, layout model.ObjectTypeLayout) (string, error) {
if util.IsObjectLayout(layout) {
md, err := s.exportService.ExportSingleInMemory(ctx, spaceId, objectId, model.Export_Markdown)
if err != nil {
return "", ErrFailedExportMarkdown
}
return md, nil
}
return md, nil
return "", nil
}
// structToDetails converts a Struct to a list of Details.

View file

@ -122,7 +122,7 @@ func (s *Service) GetTemplate(ctx context.Context, spaceId string, _ string, tem
return apimodel.ObjectWithBody{}, err
}
markdown, err := s.getMarkdownExport(ctx, spaceId, templateId)
markdown, err := s.getMarkdownExport(ctx, spaceId, templateId, model.ObjectTypeLayout(resp.ObjectView.Details[0].Details.Fields[bundle.RelationKeyResolvedLayout.String()].GetNumberValue()))
if err != nil {
return apimodel.ObjectWithBody{}, err
}