1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-26 09:47:13 +00:00

Added expedite tolerance

This commit is contained in:
M66B 2022-07-20 20:43:15 +02:00
parent 4b79f6bbee
commit 4452f1c1b2
2 changed files with 8 additions and 1 deletions

View file

@ -151,6 +151,8 @@ public class ServiceAuthenticator extends Authenticator {
long now = new Date().getTime();
Long expiration = authState.getAccessTokenExpirationTime();
boolean needsRefresh = (expiration != null && expiration < now);
if (needsRefresh)
authState.setNeedsTokenRefresh(true);
if (!needsRefresh && forceRefresh &&
expiration != null &&

View file

@ -64,6 +64,8 @@ import com.sun.mail.imap.IMAPStore;
import com.sun.mail.imap.protocol.IMAPProtocol;
import com.sun.mail.imap.protocol.IMAPResponse;
import net.openid.appauth.AuthState;
import org.json.JSONObject;
import java.io.File;
@ -2356,7 +2358,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
if (!account.isTransient(this)) {
Long expirationTime = iservice.getAccessTokenExpirationTime();
if (expirationTime != null && expirationTime < trigger) {
if (expirationTime != null &&
expirationTime < trigger &&
expirationTime > new Date().getTime()) {
expirationTime += AuthState.EXPIRY_TIME_TOLERANCE_MS;
EntityLog.log(this, EntityLog.Type.Debug, "Expedite keep alive" +
" from " + new Date(trigger) + " to " + new Date(expirationTime));
trigger = expirationTime;