|
|
|
@ -270,34 +270,20 @@ export class SessionProtocol {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is a utility function to avoid duplicate code between `getProcessedSessionRequest()` and `getSentSessionRequest()`
|
|
|
|
|
*/
|
|
|
|
|
private static async getSessionRequest(
|
|
|
|
|
device: string,
|
|
|
|
|
map: StringToNumberMap
|
|
|
|
|
): Promise<number | undefined> {
|
|
|
|
|
await SessionProtocol.fetchFromDBIfNeeded();
|
|
|
|
|
|
|
|
|
|
return map[device];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static async getSentSessionRequest(
|
|
|
|
|
device: string
|
|
|
|
|
): Promise<number | undefined> {
|
|
|
|
|
return SessionProtocol.getSessionRequest(
|
|
|
|
|
device,
|
|
|
|
|
SessionProtocol.sentSessionsTimestamp
|
|
|
|
|
);
|
|
|
|
|
await SessionProtocol.fetchFromDBIfNeeded();
|
|
|
|
|
|
|
|
|
|
return SessionProtocol.sentSessionsTimestamp[device];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static async getProcessedSessionRequest(
|
|
|
|
|
device: string
|
|
|
|
|
): Promise<number | undefined> {
|
|
|
|
|
return SessionProtocol.getSessionRequest(
|
|
|
|
|
device,
|
|
|
|
|
SessionProtocol.processedSessionsTimestamp
|
|
|
|
|
);
|
|
|
|
|
await SessionProtocol.fetchFromDBIfNeeded();
|
|
|
|
|
|
|
|
|
|
return SessionProtocol.processedSessionsTimestamp[device];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static async hasAlreadySentSessionRequest(
|
|
|
|
|