Skip to content

Commit

Permalink
fixed zoom video not creating when credentials are not valid (calcom#…
Browse files Browse the repository at this point in the history
…1329)

* fixed nextcloud

* fixed nextcloud & fastmail issues

* fixed zoom video not creating when credentials are not valid
also fixed reponse to reflect create failure.

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 22, 2021
1 parent 9d7dc09 commit 3761a75
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 3 additions & 2 deletions lib/integrations/Zoom/ZoomVideoApiAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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),
};
Expand Down
7 changes: 2 additions & 5 deletions lib/videoClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,24 @@ 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,
};
}

return {
type: credential.type,
success,
success: true,
uid,
createdEvent: createdMeeting,
originalEvent: calEvent,
Expand Down

0 comments on commit 3761a75

Please sign in to comment.