Skip to content

Commit

Permalink
improve getUserProviderTimestamps
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Jan 26, 2023
1 parent 25155d8 commit 15e0608
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/private/Collaboration/Reference/ReferenceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,13 @@ public function getUserProviderTimestamps(): array {
}
$userId = $user->getUID();
$keys = $this->config->getUserKeys($userId, 'references');
$keys = array_filter($keys, static function (string $key) {
return preg_match('/^provider-last-use_/', $key) !== false;
$prefix = 'provider-last-use_';
$keys = array_filter($keys, static function (string $key) use ($prefix) {
return str_starts_with($key, $prefix);
});
$timestamps = [];
foreach ($keys as $key) {
$providerId = preg_replace('/^provider-last-use_/', '', $key);
$providerId = substr($key, strlen($prefix));
$timestamp = (int) $this->config->getUserValue($userId, 'references', $key);
$timestamps[$providerId] = $timestamp;
}
Expand Down

0 comments on commit 15e0608

Please sign in to comment.