Filtering email search results on just value

Should catch even more duplicates, though value has both name & email
This commit is contained in:
nathan 2023-11-21 14:07:59 -07:00 committed by ralf
parent a97e34c29a
commit 9540d1f941

View File

@ -3749,9 +3749,19 @@ class mail_compose
// switch regular JSON response handling off
Api\Json\Request::isJSONRequest(false);
$results = array_reduce($results, function ($result, $option)
{
$value = $option['value'];
if(!array_key_exists($value, $result))
{
$result[$value] = $option;
}
return $result;
}, []);
//error_log(__METHOD__.__LINE__.array2string($jsArray));
header('Content-Type: application/json; charset=utf-8');
echo json_encode(array_values(array_unique($results, SORT_REGULAR)));
echo json_encode(array_values($results));
exit();
}