Plugin Directory


Ignore:
Timestamp:
11/25/2026 08:29:31 AM (10 days ago)
Author:
foldrocket
Message:

Release FoldRocket 1.5.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • foldrocket/trunk/src/Rest/Controllers/AssetsController.php

    r3821266 r3822302  
    66
    77use FoldRocket\Application\Services\AssetIndexer;
     8use FoldRocket\Application\Services\LibraryIndexStatusService;
    89use FoldRocket\Application\Services\AssetUpdater;
    910use FoldRocket\Application\Services\MediaUploadService;
    … …  
    145146                register_rest_route(
    146147                        Router::NAMESPACE,
     148                        '/assets/index-status',
     149                        array(
     150                                array(
     151                                        'methods'             => 'GET',
     152                                        'callback'            => array( $this, 'index_status' ),
     153                                        'permission_callback' => array( $this, 'can_view' ),
     154                                ),
     155                        )
     156                );
     157
     158                register_rest_route(
     159                        Router::NAMESPACE,
    147160                        '/assets/upload',
    148161                        array(
    … …  
    260273                                                        'enum'              => array( 'differential', 'full' ),
    261274                                                        'sanitize_callback' => 'sanitize_key',
     275                                                ),
     276                                                'include_usage' => array(
     277                                                        'type'              => 'boolean',
     278                                                        'default'           => true,
     279                                                        'sanitize_callback' => 'rest_sanitize_boolean',
    262280                                                ),
    263281                                        ),
    … …  
    517535
    518536        public function index_library( WP_REST_Request $request ): WP_REST_Response {
    519                 $mode   = 'full' === (string) $request->get_param( 'mode' ) ? 'full' : 'differential';
    520                 $status = ( new \FoldRocket\Application\Services\LibraryScanService() )->start( 'index', $mode );
     537                $mode          = 'full' === (string) $request->get_param( 'mode' ) ? 'full' : 'differential';
     538                $include_usage = filter_var( $request->get_param( 'include_usage' ), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ) ?? true;
     539                $status        = ( new \FoldRocket\Application\Services\LibraryScanService() )->start( 'index', $mode, $include_usage );
    521540                return new WP_REST_Response( array_merge( $status, array( 'queued' => $status['total'], 'scan' => $status ) ), 202 );
    522541        }
     542
     543        public function index_status(): WP_REST_Response {
     544                return new WP_REST_Response( ( new LibraryIndexStatusService() )->report() );
     545        }
    523546}
Note: See TracChangeset for help on using the changeset viewer.