Daily video calls (#542)
* ⬆️ Bump tailwindcss from 2.2.14 to 2.2.15 Bumps [tailwindcss](https://github.com/tailwindlabs/tailwindcss) from 2.2.14 to 2.2.15. - [Release notes](https://github.com/tailwindlabs/tailwindcss/releases) - [Changelog](https://github.com/tailwindlabs/tailwindcss/blob/master/CHANGELOG.md) - [Commits](https://github.com/tailwindlabs/tailwindcss/compare/v2.2.14...v2.2.15) --- updated-dependencies: - dependency-name: tailwindcss dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * updating cal will provide a zoom meeting url * updating cal will provide a zoom meeting url * modifying how daily emails send * modifying how daily emails send * daily table * migration updates * daily table * rebasing updates * updating Daily references to a new table * updating internal notes * merge updates, adding Daily references to book/events.ts * updated video email templates to remove Daily specific references * updating the events.ts and refactoring in the event manager * removing the package-lock * changing calendso video powered by Daily.co to cal video powered by Daily.co * updating some of the internal Daily notes * added a modal for when the call/ link is invalid * removing handle errors raw from the Daily video client * prettier formatting fixes * Added the Daily location to calendar events and updated Cal video references to Daily.co video * updating references to create in event manager to check for Daily video * fixing spacing on the cancel booking modal and adding Daily references in the event manager * formatting fixes * updating the readme file * adding a daily interface in the event manager * adding daily to the location labels * added a note to cal event parser * resolving yarn merge conflicts * updating dailyReturn to DailyReturnType * removing prettier auto and refactoring integrations: daily in the event manager * removing changes to estlintrc.json * updating read me formatting * indent space for Daily ReadMe section * resolving the merge conflicts in the yarn file Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Lola-Ojabowale <[email protected]>
This commit is contained in:
20 files changed
+761
-41
No files matched your search
+50
-2
@@ -22,6 +22,13 @@ import { getBusyVideoTimes } from "@lib/videoClient";
|
||||
import sendPayload from "@lib/webhooks/sendPayload";
|
||||
import getSubscriberUrls from "@lib/webhooks/subscriberUrls";
|
||||
|
||||
export interface DailyReturnType {
|
||||
name: string;
|
||||
url: string;
|
||||
id: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
dayjs.extend(dayjsBusinessDays);
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(isBetween);
|
||||
@@ -249,7 +256,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
|
||||
const attendeesList = [...invitee, ...guests, ...teamMembers];
|
||||
|
||||
const seed = `${users[0].username}:${dayjs(reqBody.start).utc().format()}`;
|
||||
const seed = `${users[0].username}:${dayjs(req.body.start).utc().format()}:${new Date().getTime()}`;
|
||||
const uid = translator.fromUUID(uuidv5(seed, uuidv5.URL));
|
||||
|
||||
const evt: CalendarEvent = {
|
||||
@@ -353,8 +360,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
selectedCalendars
|
||||
);
|
||||
|
||||
const videoBusyTimes = await getBusyVideoTimes(credentials);
|
||||
const videoBusyTimes = (await getBusyVideoTimes(credentials)).filter((time) => time);
|
||||
calendarBusyTimes.push(...videoBusyTimes);
|
||||
console.log("calendarBusyTimes==>>>", calendarBusyTimes);
|
||||
|
||||
const bufferedBusyTimes: BufferedBusyTimes = calendarBusyTimes.map((a) => ({
|
||||
start: dayjs(a.start).subtract(currentUser.bufferTime, "minute").toString(),
|
||||
@@ -445,6 +453,46 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
}
|
||||
}
|
||||
|
||||
//for Daily.co video calls will grab the meeting token for the call
|
||||
const isDaily = evt.location === "integrations:daily";
|
||||
|
||||
let dailyEvent: DailyReturnType;
|
||||
|
||||
if (!rescheduleUid) {
|
||||
dailyEvent = results.filter((ref) => ref.type === "daily")[0]?.createdEvent as DailyReturnType;
|
||||
} else {
|
||||
dailyEvent = results.filter((ref) => ref.type === "daily_video")[0]?.updatedEvent as DailyReturnType;
|
||||
}
|
||||
|
||||
let meetingToken;
|
||||
if (isDaily) {
|
||||
const response = await fetch("https://api.daily.co/v1/meeting-tokens", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ properties: { room_name: dailyEvent.name, is_owner: true } }),
|
||||
headers: {
|
||||
Authorization: "Bearer " + process.env.DAILY_API_KEY,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
meetingToken = await response.json();
|
||||
}
|
||||
|
||||
//for Daily.co video calls will update the dailyEventReference table
|
||||
|
||||
if (isDaily) {
|
||||
await prisma.dailyEventReference.create({
|
||||
data: {
|
||||
dailyurl: dailyEvent.url,
|
||||
dailytoken: meetingToken.token,
|
||||
booking: {
|
||||
connect: {
|
||||
uid: booking.uid,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (eventType.requiresConfirmation && !rescheduleUid) {
|
||||
await new EventOrganizerRequestMail(evt, uid).sendEmail();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import { deleteMeeting } from "@lib/videoClient";
|
||||
import sendPayload from "@lib/webhooks/sendPayload";
|
||||
import getSubscriberUrls from "@lib/webhooks/subscriberUrls";
|
||||
|
||||
import { dailyDeleteMeeting } from "../../lib/dailyVideoClient";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
// just bail if it not a DELETE
|
||||
if (req.method !== "DELETE" && req.method !== "POST") {
|
||||
@@ -37,6 +39,7 @@ export default async function handler(req, res) {
|
||||
},
|
||||
},
|
||||
attendees: true,
|
||||
location: true,
|
||||
references: {
|
||||
select: {
|
||||
uid: true,
|
||||
@@ -118,6 +121,13 @@ export default async function handler(req, res) {
|
||||
return await deleteMeeting(credential, bookingRefUid);
|
||||
}
|
||||
}
|
||||
//deleting a Daily meeting
|
||||
|
||||
const isDaily = bookingToDelete.location === "integrations:daily";
|
||||
const bookingUID = bookingToDelete.references.filter((ref) => ref.type === "daily")[0]?.uid;
|
||||
if (isDaily) {
|
||||
return await dailyDeleteMeeting(credential, bookingUID);
|
||||
}
|
||||
});
|
||||
|
||||
if (bookingToDelete && bookingToDelete.paid) {
|
||||
|
||||
Reference in new issue
Block a user