Scheduling infrastructure for absolutely everyone.
fixed zoom video not creating when credentials are not valid (#1329)
Nathaniel3761a75b28bc
diff --git a/lib/integrations/Zoom/ZoomVideoApiAdapter.ts b/lib/integrations/Zoom/ZoomVideoApiAdapter.tsindex 8ac07b66ee4..ea48ddad6bb 100644--- a/lib/integrations/Zoom/ZoomVideoApiAdapter.ts+++ b/lib/integrations/Zoom/ZoomVideoApiAdapter.ts@@ -69,7 +69,8 @@ interface ZoomToken {const zoomAuth = (credential: Credential) => {const credentialKey = credential.key as unknown as ZoomToken;- const isExpired = (expiryDate: number) => expiryDate < Date.now();+ const isTokenValid = (token: ZoomToken) =>+ token && token.token_type && token.access_token && (token.expires_in || token.expiry_date) < Date.now();const authHeader ="Basic " +Buffer.from(process.env.ZOOM_CLIENT_ID + ":" + process.env.ZOOM_CLIENT_SECRET).toString("base64");@@ -107,7 +108,7 @@ const zoomAuth = (credential: Credential) => {return {getToken: () =>- !isExpired(credentialKey.expires_in || credentialKey.expiry_date)+ !isTokenValid(credentialKey)? Promise.resolve(credentialKey.access_token): refreshAccessToken(credentialKey.refresh_token),};diff --git a/lib/videoClient.ts b/lib/videoClient.tsindex e57d23476fb..7e5d7168f70 100644--- a/lib/videoClient.ts+++ b/lib/videoClient.ts@@ -68,19 +68,16 @@ const createMeeting = async ();}- let success = true;-const videoAdapters = getVideoAdapters([credential]);const [firstVideoAdapter] = videoAdapters;const createdMeeting = await firstVideoAdapter.createMeeting(calEvent).catch((e) => {log.error("createMeeting failed", e, calEvent);- success = false;});if (!createdMeeting) {return {type: credential.type,- success,+ success: false,uid,originalEvent: calEvent,};@@ -88,7 +85,7 @@ const createMeeting = async (return {type: credential.type,- success,+ success: true,uid,createdEvent: createdMeeting,originalEvent: calEvent,