1111
1212use Exception ;
1313use NCU \Sharing \Share ;
14+ use NCU \Sharing \ShareState ;
1415use NCU \Sharing \Source \IShareSourceType ;
1516use OC \Core \Command \Base ;
1617use Symfony \Component \Console \Input \InputInterface ;
1718use Symfony \Component \Console \Input \InputOption ;
1819use Symfony \Component \Console \Output \OutputInterface ;
20+ use ValueError ;
1921
2022final class GetShares extends SharingBase {
2123 #[\Override]
@@ -25,6 +27,7 @@ public function configure(): void {
2527 ->setDescription ('Get multiple shares. ' )
2628 ->addOption ('filter-source-type-class ' , '' , InputOption::VALUE_REQUIRED , 'Source type class to filter by ' )
2729 ->addOption ('filter-source-type-value ' , '' , InputOption::VALUE_REQUIRED , 'Source type value to filter by ' )
30+ ->addOption ('filter-state ' , '' , InputOption::VALUE_REQUIRED , 'State to filter by ' )
2831 ->addOption ('last-share-id ' , '' , InputOption::VALUE_REQUIRED , 'Share ID to use as an offset ' )
2932 ->addOption ('limit ' , '' , InputOption::VALUE_REQUIRED , 'Maximum number of shares to return ' );
3033 parent ::configure ();
@@ -38,6 +41,17 @@ public function execute(InputInterface $input, OutputInterface $output): int {
3841 $ filterSourceTypeClass = $ input ->getOption ('filter-source-type-class ' );
3942 /** @var ?class-string<IShareSourceType> $filterSourceTypeValue */
4043 $ filterSourceTypeValue = $ input ->getOption ('filter-source-type-value ' );
44+ /** @var ?string $filterState */
45+ $ filterState = $ input ->getOption ('filter-state ' );
46+ if ($ filterState !== null ) {
47+ try {
48+ $ filterState = ShareState::from ($ filterState );
49+ } catch (ValueError $ valueError ) {
50+ $ output ->writeln ($ valueError ->getMessage ());
51+ return Base::FAILURE ;
52+ }
53+ }
54+
4155 /** @var ?string $lastShareID */
4256 $ lastShareID = $ input ->getOption ('last-share-id ' );
4357 /** @var ?string $limit */
@@ -53,7 +67,7 @@ public function execute(InputInterface $input, OutputInterface $output): int {
5367 try {
5468 $ this ->dbConnection ->beginTransaction ();
5569
56- $ shares = $ this ->manager ->getShares ($ this ->accessContext , $ filterSourceTypeClass , $ filterSourceTypeValue , $ lastShareID , $ limit );
70+ $ shares = $ this ->manager ->getShares ($ this ->accessContext , $ filterSourceTypeClass , $ filterSourceTypeValue , $ filterState , $ lastShareID , $ limit );
5771 $ this ->dbConnection ->commit ();
5872
5973 $ data = Share::formatMultiple ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ shares );
0 commit comments