This commit is contained in:
venture
2026-11-15 09:04:18 +01:00
parent 03da7d9fff
commit 29a6ab40f0
16 changed files with 660 additions and 112 deletions
+17 -2
View File
@@ -9,9 +9,17 @@ import (
"mediarr/database"
"mediarr/ident"
"mediarr/permission"
)
func (s *Service) CreateLibrary(ctx context.Context, params CreateLibraryParams) (*Document, error) {
func (s *Service) CreateLibrary(ctx context.Context, actorID ident.UUID, params CreateLibraryParams) (*Document, error) {
if err := s.requireActive(ctx, actorID); err != nil {
return nil, err
}
if params.OwnerID != actorID || params.CreatedBy != actorID {
return nil, fmt.Errorf("%w: owner_id et created_by doivent être l'acteur", ErrPermissionDenied)
}
name, nameKey, err := normalizeName(params.Name)
if err != nil {
return nil, err
@@ -64,7 +72,11 @@ func (s *Service) CreateLibrary(ctx context.Context, params CreateLibraryParams)
return documentFromDB(created), nil
}
func (s *Service) CreateFolder(ctx context.Context, params CreateFolderParams) (*Document, error) {
func (s *Service) CreateFolder(ctx context.Context, actorID ident.UUID, params CreateFolderParams) (*Document, error) {
if params.OwnerID != actorID || params.CreatedBy != actorID {
return nil, fmt.Errorf("%w: owner_id et created_by doivent être l'acteur", ErrPermissionDenied)
}
name, nameKey, err := normalizeName(params.Name)
if err != nil {
return nil, err
@@ -83,6 +95,9 @@ func (s *Service) CreateFolder(ctx context.Context, params CreateFolderParams) (
if !isContainerKind(parent.Kind) {
return nil, fmt.Errorf("%w: %s", ErrInvalidParent, parent.Kind)
}
if err := s.can(ctx, actorID, params.ParentID, permission.Create); err != nil {
return nil, err
}
id, err := ident.NewV7()
if err != nil {