Skip to content

Commit

Permalink
Exclude groups for sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwezepoel committed Nov 12, 2024
1 parent e38ea33 commit 03e4ba8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions apps/files_sharing/lib/Controller/ShareesAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,27 @@ public function search(string $search = '', ?string $itemType = null, int $page
$result['exact'] = array_merge($this->result['exact'], $result['exact']);
}
$this->result = array_merge($this->result, $result);

// Get a list of groups to exclude from search results
$blacklisted_groups = $this->config->getSystemValue('blacklisted_groups', true);

// Check and filter normal 'groups' array at the top level and the nested 'exact' level
if (isset($this->result['groups'])) {
$this->result['groups'] = array_filter($this->result['groups'], function($group) use ($blacklisted_groups) {
return !in_array($group['label'], $blacklisted_groups);
});
// Reindex array to maintain sequential numeric keys
$this->result['groups'] = array_values($this->result['groups']);
}

if (isset($this->result['exact']['groups'])) {
$this->result['exact']['groups'] = array_filter($this->result['exact']['groups'], function($group) use ($blacklisted_groups) {
return !in_array($group['label'], $blacklisted_groups);
});
// Reindex array to maintain sequential numeric keys
$this->result['exact']['groups'] = array_values($this->result['exact']['groups']);
}

$response = new DataResponse($this->result);

if ($hasMoreResults) {
Expand Down

0 comments on commit 03e4ba8

Please sign in to comment.