Skip to content

Commit

Permalink
Merge pull request #4 from julien-nc/feat/deleteSources
Browse files Browse the repository at this point in the history
add deleteSources function
  • Loading branch information
marcelklehr authored Nov 9, 2023
2 parents 539b8ce + 2ed09fb commit 84ce529
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/BackgroundJobs/IndexerJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ protected function index(array $files): void {
}
$this->langRopeService->indexSources($userId, [$source]);
}
try {
$this->queue->removeFromQueue($queueFile);
} catch (Exception $e) {
$this->logger->error('Could not remove file from queue', ['exception' => $e]);
}
}
}
}
27 changes: 27 additions & 0 deletions lib/Service/LangRopeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,33 @@ private function getExApp() {
return $exApp;
}

/**
* @param string $userId
* @param Source[] $sourceNames
* @return void
*/
public function deleteSources(string $userId, array $sourceNames): void {
if (count($sourceNames) === 0) {
return;
}

$params = [
'userId' => $userId,
'sourceNames' => $sourceNames,
];

$exApp = $this->getExApp();
if ($exApp === null) {
return;
}
$this->requestToExApp($userId, $exApp, '/deleteSources', 'POST', $params);
}

/**
* @param string $userId
* @param Source[] $sources
* @return void
*/
public function indexSources(string $userId, array $sources): void {
if (count($sources) === 0) {
return;
Expand Down

0 comments on commit 84ce529

Please sign in to comment.