mirror of
https://github.com/nextcloud/server.git
synced 2026-02-11 23:04:22 -05:00
chore: Refactor callForSeenUsers to use getSeenUsers
Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
parent
0aa31997ed
commit
575cb92bbb
1 changed files with 6 additions and 22 deletions
|
|
@ -646,30 +646,14 @@ class Manager extends PublicEmitter implements IUserManager {
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Closure $callback
|
||||
* @psalm-param \Closure(\OCP\IUser):?bool $callback
|
||||
* @since 11.0.0
|
||||
*/
|
||||
public function callForSeenUsers(\Closure $callback) {
|
||||
$limit = 1000;
|
||||
$offset = 0;
|
||||
do {
|
||||
$userIds = $this->getSeenUserIds($limit, $offset);
|
||||
$offset += $limit;
|
||||
foreach ($userIds as $userId) {
|
||||
foreach ($this->backends as $backend) {
|
||||
if ($backend->userExists($userId)) {
|
||||
$user = $this->getUserObject($userId, $backend, false);
|
||||
$return = $callback($user);
|
||||
if ($return === false) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$users = $this->getSeenUsers();
|
||||
foreach ($users as $user) {
|
||||
$return = $callback($user);
|
||||
if ($return === false) {
|
||||
return;
|
||||
}
|
||||
} while (count($userIds) >= $limit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue