mirror of
https://github.com/nextcloud/server.git
synced 2026-06-25 08:31:11 -04:00
fix: trim duplicate search results for external share
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
This commit is contained in:
parent
739b43a003
commit
d29c43d91e
1 changed files with 19 additions and 3 deletions
|
|
@ -94,13 +94,17 @@ class Search implements ISearch {
|
|||
$emailType = new SearchResultType('emails');
|
||||
$remoteType = new SearchResultType('remotes');
|
||||
|
||||
if (!isset($allResults[$remoteType->getLabel()])
|
||||
|| !isset($allResults[$emailType->getLabel()])) {
|
||||
$emailLabel = $emailType->getLabel();
|
||||
$emailEntries = array_merge(
|
||||
$allResults['exact'][$emailLabel] ?? [],
|
||||
$allResults[$emailLabel] ?? []
|
||||
);
|
||||
if ($emailEntries === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
$mailIdMap = [];
|
||||
foreach ($allResults[$emailType->getLabel()] as $mailRow) {
|
||||
foreach ($emailEntries as $mailRow) {
|
||||
// sure, array_reduce looks nicer, but foreach needs less resources and is faster
|
||||
if (!isset($mailRow['uuid'])) {
|
||||
continue;
|
||||
|
|
@ -116,5 +120,17 @@ class Search implements ISearch {
|
|||
$searchResult->removeCollaboratorResult($emailType, $mailIdMap[$resultRow['uuid']]);
|
||||
}
|
||||
}
|
||||
$lookupType = new SearchResultType('lookup');
|
||||
if (isset($allResults[$lookupType->getLabel()])) {
|
||||
foreach ($allResults[$lookupType->getLabel()] as $resultRow) {
|
||||
$userid = $resultRow['extra']['userid']['value'] ?? null;
|
||||
if ($userid === null) {
|
||||
continue;
|
||||
}
|
||||
if (isset($mailIdMap[$userid])) {
|
||||
$searchResult->removeCollaboratorResult($emailType, $mailIdMap[$userid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue