fix: Credential of type video wrong id on bookingReference (#9281)

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Omar López <zomars@me.com>
This commit is contained in:
alannnc 2023-07-06 14:39:33 -07:00 committed by GitHub
parent cc0c686e65
commit d0707422b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 9 deletions

View File

@ -56,10 +56,10 @@ const meetingTokenSchema = z.object({
/** @deprecated use metadata on index file */
export const FAKE_DAILY_CREDENTIAL: CredentialPayload & { invalid: boolean } = {
id: +new Date().getTime(),
id: 0,
type: "daily_video",
key: { apikey: process.env.DAILY_API_KEY },
userId: +new Date().getTime(),
userId: 0,
appId: "daily-video",
invalid: false,
teamId: undefined,

View File

@ -116,11 +116,11 @@ function getApps(userCredentials: CredentialData[]) {
/** If the app is a globally installed one, let's inject it's key */
if (appMeta.isGlobal) {
credentials.push({
id: +new Date().getTime(),
id: 0,
type: appMeta.type,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
key: appMeta.key!,
userId: +new Date().getTime(),
userId: 0,
appId: appMeta.slug,
invalid: false,
});

View File

@ -130,13 +130,14 @@ export default class EventManager {
return result.type.includes("_calendar");
};
// References can be any type: calendar/video
const referencesToCreate = results.map((result) => {
let createdEventObj: createdEventSchema | null = null;
if (typeof result?.createdEvent === "string") {
createdEventObj = createdEventSchema.parse(JSON.parse(result.createdEvent));
}
if (isCalendarResult(result)) {
const isCalendarType = isCalendarResult(result);
if (isCalendarType) {
evt.iCalUID = result.iCalUID || undefined;
}
@ -146,8 +147,8 @@ export default class EventManager {
meetingId: createdEventObj ? createdEventObj.id : result.createdEvent?.id?.toString(),
meetingPassword: createdEventObj ? createdEventObj.password : result.createdEvent?.password,
meetingUrl: createdEventObj ? createdEventObj.onlineMeetingUrl : result.createdEvent?.url,
externalCalendarId: evt.destinationCalendar?.externalId,
credentialId: evt.destinationCalendar?.credentialId,
externalCalendarId: isCalendarType ? evt.destinationCalendar?.externalId : undefined,
credentialId: isCalendarType ? evt.destinationCalendar?.credentialId : result.credentialId,
};
});
@ -186,7 +187,7 @@ export default class EventManager {
meetingPassword: result.createdEvent?.password,
meetingUrl: result.createdEvent?.url,
externalCalendarId: evt.destinationCalendar?.externalId,
credentialId: evt.destinationCalendar?.credentialId,
credentialId: result.credentialId ?? evt.destinationCalendar?.credentialId,
};
});
@ -504,6 +505,7 @@ export default class EventManager {
success: false,
uid: "",
originalEvent: event,
credentialId: cred.id,
};
}
const { externalCalendarId: bookingExternalCalendarId, meetingId: bookingRefUid } =
@ -526,6 +528,7 @@ export default class EventManager {
success: false,
uid: "",
originalEvent: event,
credentialId: 0,
},
]);
}

View File

@ -67,6 +67,7 @@ const createMeeting = async (credential: CredentialWithAppName, calEvent: Calend
originalEvent: CalendarEvent;
success: boolean;
createdEvent: VideoCallData | undefined;
credentialId: number;
} = {
appName: credential.appName,
type: credential.type,
@ -74,6 +75,7 @@ const createMeeting = async (credential: CredentialWithAppName, calEvent: Calend
originalEvent: calEvent,
success: false,
createdEvent: undefined,
credentialId: credential.id,
};
try {
// Check to see if video app is enabled

View File

@ -22,6 +22,7 @@ export interface EventResult<T> {
originalEvent: CalendarEvent;
calError?: string;
calWarnings?: string[];
credentialId?: number;
}
export interface CreateUpdateResult {