mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-21 23:57:00 +00:00
4548f69de8
Provide the minimal components required to support an Outlook add-in: user authentication, JWT retrieval, and API calls to generate meeting links. This implementation is an early alpha: developer experience is limited, documentation is incomplete, and the solution is not white-labeled. It's too early to consider these parts ready to ship into production. As a result, it is currently only available within the DINUM frontend image.
48 lines
1.0 KiB
JavaScript
48 lines
1.0 KiB
JavaScript
const { pollSession } = require("./api");
|
|
|
|
const POLLING_INTERVAL_MS = 1000;
|
|
const POLLING_TIMEOUT_MS = 3 * 60 * 1000;
|
|
const POLLING_MAX_ATTEMPTS = POLLING_TIMEOUT_MS / POLLING_INTERVAL_MS;
|
|
|
|
function isPollAuthenticated(sessionData) {
|
|
return sessionData.state === "authenticated" && sessionData.access_token;
|
|
}
|
|
|
|
function startPolling(csrfToken, { onSuccess, onTimeout, onError }) {
|
|
let pollCount = 0;
|
|
let timeoutId = null;
|
|
let cancelled = false;
|
|
|
|
const poll = () => {
|
|
if (pollCount++ >= POLLING_MAX_ATTEMPTS) {
|
|
onTimeout?.();
|
|
return;
|
|
}
|
|
|
|
pollSession(csrfToken)
|
|
.then((sessionData) => {
|
|
if (cancelled) return;
|
|
if (isPollAuthenticated(sessionData)) {
|
|
onSuccess?.(sessionData);
|
|
return;
|
|
}
|
|
timeoutId = setTimeout(poll, POLLING_INTERVAL_MS);
|
|
})
|
|
.catch((err) => {
|
|
if (cancelled) return;
|
|
onError?.(err);
|
|
});
|
|
};
|
|
|
|
poll();
|
|
|
|
return () => {
|
|
cancelled = true;
|
|
if (timeoutId) clearTimeout(timeoutId);
|
|
};
|
|
}
|
|
|
|
module.exports = {
|
|
startPolling,
|
|
};
|