ingest documents
This commit is contained in:
@@ -46,6 +46,37 @@ func (s *Service) Rename(ctx context.Context, actorID, documentID ident.UUID, na
|
||||
return documentFromDB(updated), nil
|
||||
}
|
||||
|
||||
func (s *Service) SetMetadata(ctx context.Context, actorID, documentID ident.UUID, metadata string) (*Document, error) {
|
||||
if err := s.requireActive(ctx, actorID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := s.getActiveDocument(ctx, documentID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.can(ctx, actorID, documentID, permission.Write); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
normalized, err := normalizeMetadata(metadata)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
updated, err := s.db.WriteQueries.UpdateDocumentMetadata(ctx, database.UpdateDocumentMetadataParams{
|
||||
Metadata: normalized,
|
||||
UpdatedAt: nowMillis(),
|
||||
ID: documentID,
|
||||
})
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, fmt.Errorf("%w: %s", ErrDocumentNotFound, documentID)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return documentFromDB(updated), nil
|
||||
}
|
||||
|
||||
func (s *Service) Move(ctx context.Context, actorID, documentID, newParentID ident.UUID) (*Document, error) {
|
||||
document, err := s.getActiveDocument(ctx, documentID)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user