Skip to content

Commit

Permalink
Using CirclesManager
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Aug 10, 2021
1 parent 1d70a78 commit c57f2a5
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions lib/Service/SearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@
namespace OCA\FullTextSearch\Service;


use ArtificialOwl\MySmallPhpTools\Traits\Nextcloud\nc22\TNC22Logger;
use Exception;
use OC;
use OC\App\AppManager;
use OC\FullTextSearch\Model\DocumentAccess;
use OC\User\NoUserException;
use OCA\Circles\Api\v1\Circles;
use OCA\Circles\CirclesManager;
use OCA\Circles\Model\Circle;
use OCA\FullTextSearch\AppInfo\Application;
use OCA\FullTextSearch\Exceptions\EmptySearchException;
use OCA\FullTextSearch\Exceptions\ProviderDoesNotExistException;
use OCA\FullTextSearch\Model\SearchRequest;
Expand All @@ -59,6 +63,9 @@
class SearchService implements ISearchService {


use TNC22Logger;


/** @var string */
private $userId;

Expand Down Expand Up @@ -111,6 +118,8 @@ public function __construct(
$this->providerService = $providerService;
$this->platformService = $platformService;
$this->miscService = $miscService;

$this->setup('app', Application::APP_ID);
}


Expand Down Expand Up @@ -215,16 +224,19 @@ private function getDocumentAccessFromUser(IUser $user): IDocumentAccess {
$rights->setViewerId($user->getUID());
$rights->setGroups($this->groupManager->getUserGroupIds($user));

if ($this->appManager->isEnabledForUser('circles', $user)) {
try {
$rights->setCircles(Circles::joinedCircleIds($user->getUID()));
} catch (Exception $e) {
$this->miscService->log('Circles is set as enabled but: ' . $e->getMessage());
}
try {
/** @var CirclesManager $circleManager */
$circleManager = OC::$server->get(CirclesManager::class);
$circleManager->startsession();
$circleIds = array_map(
function (Circle $circle): string {
return $circle->getSingleId();
}, $circleManager->getCircles()
);
$rights->setCircles($circleIds);
} catch (Exception $e) {
}

return $rights;
}


}

0 comments on commit c57f2a5

Please sign in to comment.