Skip to content

Commit 9ea513f

Browse files
juliusknorrmejo-
authored andcommitted
fix: Catch exceptions at Circle::getInitiator during mountpoint setup
Signed-off-by: Julius Knorr <jus@bitgrid.net>
1 parent a7e344c commit 9ea513f

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

lib/Mount/MountProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use OC\Files\Cache\Cache;
1313
use OCA\Collectives\Db\Collective;
1414
use OCA\Collectives\Fs\UserFolderHelper;
15+
use OCA\Collectives\Service\CircleException;
1516
use OCA\Collectives\Service\CollectiveHelper;
1617
use OCA\Collectives\Service\MissingDependencyException;
1718
use OCA\Collectives\Service\NotFoundException;
@@ -50,7 +51,7 @@ public function getFoldersForUser(IUser $user): array {
5051

5152
try {
5253
$collectives = $this->collectiveHelper->getCollectivesForUser($user->getUID(), true, false);
53-
} catch (QueryException|MissingDependencyException|NotFoundException|NotPermittedException $e) {
54+
} catch (QueryException|MissingDependencyException|NotFoundException|NotPermittedException|CircleException $e) {
5455
$this->log($e);
5556
return $folders;
5657
}

lib/Service/CircleHelper.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,9 @@ public function getLevel(string $circleId, string $userId): int {
285285
$member = $circle->getInitiator();
286286
} catch (CircleNotFoundException $e) {
287287
throw new NotFoundException($e->getMessage(), 0, $e);
288-
} catch (RequestBuilderException|
289-
FederatedItemException $e) {
290-
throw new NotPermittedException($e->getMessage(), 0, $e);
291-
}
288+
} catch (RequestBuilderException|FederatedItemException $e) {
289+
throw new NotPermittedException($e->getMessage(), 0, $e);
290+
}
292291

293292
return $member->getLevel();
294293
}

lib/Service/CollectiveHelper.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public function __construct(
2222
}
2323

2424
/**
25+
* @throws CircleException
2526
* @throws NotFoundException
2627
* @throws NotPermittedException
2728
* @throws MissingDependencyException
@@ -36,7 +37,11 @@ public function getCollectivesForUser(string $userId, bool $getLevel = true, boo
3637
$cid = $c->getCircleId();
3738
$circle = $circles[$cid];
3839
$c->setName($circle->getSanitizedName());
39-
$c->setLevel($getLevel ? $circle->getInitiator()->getLevel(): 0);
40+
try {
41+
$c->setLevel($getLevel ? $circle->getInitiator()->getLevel(): 0);
42+
} catch (\Exception $e) {
43+
throw new CircleException($e->getMessage(), 0, $e);
44+
}
4045
if ($getUserSettings) {
4146
// TODO: merge queries for collective and user settings into one?
4247
$settings = $this->collectiveUserSettingsMapper->findByCollectiveAndUser($c->getId(), $userId);
@@ -50,6 +55,7 @@ public function getCollectivesForUser(string $userId, bool $getLevel = true, boo
5055
}
5156

5257
/**
58+
* @throws CircleException
5359
* @throws NotFoundException
5460
* @throws NotPermittedException
5561
* @throws MissingDependencyException
@@ -63,7 +69,11 @@ public function getCollectivesTrashForUser(string $userId): array {
6369
$cid = $c->getCircleId();
6470
$circle = $circles[$cid];
6571
$c->setName($circle->getSanitizedName());
66-
$c->setLevel($circle->getInitiator()->getLevel());
72+
try {
73+
$c->setLevel($circle->getInitiator()->getLevel());
74+
} catch (\Exception $e) {
75+
throw new CircleException($e->getMessage(), 0, $e);
76+
}
6777
}
6878
return $collectives;
6979
}

0 commit comments

Comments
 (0)