@@ -368,6 +368,14 @@ func (i *Project) Create(ctx context.Context, input interfaces.CreateProjectPara
368368 visibility := project .VisibilityPublic
369369
370370 if i .policyChecker != nil {
371+ operationAllowed , err := i .policyChecker .CheckPolicy (ctx , gateway .CreateGeneralOperationAllowedCheckRequest (input .WorkspaceID ))
372+ if err != nil {
373+ return nil , err
374+ }
375+ if ! operationAllowed .Allowed {
376+ return nil , visualizer .ErrorWithCallerLogging (ctx , "operation is disabled by overused seat" , errors .New ("operation is disabled by overused seat" ))
377+ }
378+
371379 errPrivate := i .checkGeneralPolicy (ctx , input .WorkspaceID , project .VisibilityPrivate )
372380 if errPrivate != nil {
373381 visibility = project .VisibilityPublic
@@ -411,6 +419,15 @@ func (i *Project) Update(ctx context.Context, p interfaces.UpdateProjectParam, o
411419 if err != nil {
412420 return nil , err
413421 }
422+
423+ operationAllowed , err := i .policyChecker .CheckPolicy (ctx , gateway .CreateGeneralOperationAllowedCheckRequest (prj .Workspace ()))
424+ if err != nil {
425+ return nil , err
426+ }
427+ if ! operationAllowed .Allowed {
428+ return nil , visualizer .ErrorWithCallerLogging (ctx , "operation is disabled by over used seat" , errors .New ("operation is disabled by over used seat" ))
429+ }
430+
414431 if err := i .CanWriteWorkspace (prj .Workspace (), operator ); err != nil {
415432 return nil , err
416433 }
@@ -542,6 +559,13 @@ func (i *Project) UpdateVisibility(ctx context.Context, pid id.ProjectID, visibi
542559 if err != nil {
543560 return nil , err
544561 }
562+ operationAllowed , err := i .policyChecker .CheckPolicy (ctx , gateway .CreateGeneralOperationAllowedCheckRequest (prj .Workspace ()))
563+ if err != nil {
564+ return nil , err
565+ }
566+ if ! operationAllowed .Allowed {
567+ return nil , visualizer .ErrorWithCallerLogging (ctx , "operation is disabled by over used seat" , errors .New ("operation is disabled by over used seat" ))
568+ }
545569
546570 if err := i .CanWriteWorkspace (prj .Workspace (), operator ); err != nil {
547571 return nil , err
@@ -718,6 +742,14 @@ func (i *Project) Publish(ctx context.Context, params interfaces.PublishProjectP
718742 return nil , err
719743 }
720744
745+ operationAllowed , err := i .policyChecker .CheckPolicy (ctx , gateway .CreateGeneralOperationAllowedCheckRequest (prj .Workspace ()))
746+ if err != nil {
747+ return nil , err
748+ }
749+ if ! operationAllowed .Allowed {
750+ return nil , visualizer .ErrorWithCallerLogging (ctx , "operation is disabled by over used seat" , errors .New ("operation is disabled by over used seat" ))
751+ }
752+
721753 sc , err := i .sceneRepo .FindByProject (ctx , prj .ID ())
722754 if err != nil {
723755 return nil , err
@@ -911,6 +943,14 @@ func (i *Project) Delete(ctx context.Context, projectID id.ProjectID, operator *
911943 return err
912944 }
913945
946+ operationAllowed , err := i .policyChecker .CheckPolicy (ctx , gateway .CreateGeneralOperationAllowedCheckRequest (prj .Workspace ()))
947+ if err != nil {
948+ return err
949+ }
950+ if ! operationAllowed .Allowed {
951+ return visualizer .ErrorWithCallerLogging (ctx , "operation is disabled by over used seat" , errors .New ("operation is disabled by over used seat" ))
952+ }
953+
914954 deleter := ProjectDeleter {
915955 SceneDeleter : SceneDeleter {
916956 Scene : i .sceneRepo ,
@@ -943,6 +983,14 @@ func (i *Project) ExportProjectData(ctx context.Context, pid id.ProjectID, zipWr
943983 return nil , errors .New ("project " + err .Error ())
944984 }
945985
986+ operationAllowed , err := i .policyChecker .CheckPolicy (ctx , gateway .CreateGeneralOperationAllowedCheckRequest (prj .Workspace ()))
987+ if err != nil {
988+ return nil , err
989+ }
990+ if ! operationAllowed .Allowed {
991+ return nil , visualizer .ErrorWithCallerLogging (ctx , "operation is disabled by over used seat" , errors .New ("operation is disabled by over used seat" ))
992+ }
993+
946994 if prj .IsDeleted () {
947995 fmt .Printf ("Error Deleted project: %v\n " , prj .ID ())
948996 return nil , errors .New ("This project is deleted" )
0 commit comments