Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: Refactor callForSeenUsers to use getSeenUsers
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge authored and backportbot[bot] committed Mar 31, 2025
commit 822761af707eeb518757eca4075be56748cca884
28 changes: 6 additions & 22 deletions lib/private/User/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,30 +620,14 @@ public function countSeenUsers() {
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);
}
}

/**
Expand Down