Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ protected function registerCollaborationResources() {
}

public function registerFullTextSearch() {
if (Util::getVersion()[0] < 16) {
if (Util::getVersion()[0] < 16 || !\OC::$server->getAppManager()->isEnabledForUser('fulltextsearch')) {
return;
}

Expand Down
41 changes: 26 additions & 15 deletions lib/Service/FullTextSearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use OCA\Deck\Provider\DeckProvider;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\FullTextSearch\Exceptions\FullTextSearchAppNotAvailableException;
use OCP\FullTextSearch\IFullTextSearchManager;
use OCP\FullTextSearch\Model\IDocumentAccess;
use OCP\FullTextSearch\Model\IIndex;
Expand Down Expand Up @@ -95,9 +96,12 @@ public function onCardCreated(GenericEvent $e) {
$cardId = $e->getArgument('id');
$userId = $e->getArgument('userId');

$this->fullTextSearchManager->createIndex(
DeckProvider::DECK_PROVIDER_ID, (string)$cardId, $userId, IIndex::INDEX_FULL
);
try {
$this->fullTextSearchManager->createIndex(
DeckProvider::DECK_PROVIDER_ID, (string)$cardId, $userId, IIndex::INDEX_FULL
);
} catch (FullTextSearchAppNotAvailableException $e) {
}
}


Expand All @@ -107,9 +111,12 @@ public function onCardCreated(GenericEvent $e) {
public function onCardUpdated(GenericEvent $e) {
$cardId = $e->getArgument('id');

$this->fullTextSearchManager->updateIndexStatus(
try {
$this->fullTextSearchManager->updateIndexStatus(
DeckProvider::DECK_PROVIDER_ID, (string)$cardId, IIndex::INDEX_CONTENT
);
} catch (FullTextSearchAppNotAvailableException $e) {
}
}


Expand All @@ -119,27 +126,33 @@ public function onCardUpdated(GenericEvent $e) {
public function onCardDeleted(GenericEvent $e) {
$cardId = $e->getArgument('id');

$this->fullTextSearchManager->updateIndexStatus(
DeckProvider::DECK_PROVIDER_ID, (string)$cardId, IIndex::INDEX_REMOVE
);
try {
$this->fullTextSearchManager->updateIndexStatus(
DeckProvider::DECK_PROVIDER_ID, (string)$cardId, IIndex::INDEX_REMOVE
);
} catch (FullTextSearchAppNotAvailableException $e) {
}
}


/**
* @param GenericEvent $e
*/
public function onBoardShares(GenericEvent $e) {
$boardId = $e->getArgument('boardId');
$boardId = (int)$e->getArgument('boardId');

$cards = array_map(
function(Card $item) {
return $item->getId();
},
$this->getCardsFromBoard($boardId)
);
$this->fullTextSearchManager->updateIndexesStatus(
DeckProvider::DECK_PROVIDER_ID, $cards, IIndex::INDEX_META
);
try {
$this->fullTextSearchManager->updateIndexesStatus(
DeckProvider::DECK_PROVIDER_ID, $cards, IIndex::INDEX_META
);
} catch (FullTextSearchAppNotAvailableException $e) {
}
}


Expand Down Expand Up @@ -167,7 +180,7 @@ public function fillIndexDocument(IIndexDocument $document) {

$document->setTitle($card->getTitle());
$document->setContent($card->getDescription());
$document->setAccess($this->generateDocumentAccessFromCardId($card->getId()));
$document->setAccess($this->generateDocumentAccessFromCardId((int)$card->getId()));
}


Expand All @@ -181,9 +194,7 @@ public function fillIndexDocument(IIndexDocument $document) {
public function generateDocumentAccessFromCardId(int $cardId): IDocumentAccess {
$board = $this->getBoardFromCardId($cardId);

$access = new DocumentAccess($board->getOwner());

return $access;
return new DocumentAccess($board->getOwner());
}


Expand Down