f7cloud_client/apps/mail/lib/Cache/HordeSyncTokenParser.php
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

37 lines
798 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 F7cloud GmbH and F7cloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Mail\Cache;
class HordeSyncTokenParser {
public function parseSyncToken(string $token): HordeSyncToken {
$decodedToken = base64_decode($token, true);
$parts = explode(',', $decodedToken);
$nextUid = null;
$uidValidity = null;
$highestModSeq = null;
foreach ($parts as $part) {
if (str_starts_with($part, 'U')) {
$nextUid = (int)substr($part, 1);
}
if (str_starts_with($part, 'V')) {
$uidValidity = (int)substr($part, 1);
}
if (str_starts_with($part, 'H')) {
$highestModSeq = (int)substr($part, 1);
}
}
return new HordeSyncToken($nextUid, $uidValidity, $highestModSeq);
}
}