feat: allow users to set google meet as a location for events (#287)
* feat: allow users to set google meet as a location for events - add google meet location with support for other integrations * return location types from server also avoids potential leaks of user credentials * chore: remove unused variable * fix: return minimal required data from server
This commit is contained in:
1 parent
2a11bcc7f5
commit
7690350124
6 files changed
+550
-314
No files matched your search
@@ -7,9 +7,30 @@ import short from 'short-uuid';
|
||||
import {createMeeting, updateMeeting} from "../../../lib/videoClient";
|
||||
import EventAttendeeMail from "../../../lib/emails/EventAttendeeMail";
|
||||
import {getEventName} from "../../../lib/event";
|
||||
|
||||
import { LocationType } from '../../../lib/location';
|
||||
import merge from "lodash.merge"
|
||||
const translator = short();
|
||||
|
||||
interface p {
|
||||
location: string
|
||||
}
|
||||
|
||||
const getLocationRequestFromIntegration = ({location}: p) => {
|
||||
if (location === LocationType.GoogleMeet.valueOf()) {
|
||||
const requestId = uuidv5(location, uuidv5.URL)
|
||||
|
||||
return {
|
||||
conferenceData: {
|
||||
createRequest: {
|
||||
requestId: requestId
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const {user} = req.query;
|
||||
|
||||
@@ -43,19 +64,38 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
}
|
||||
});
|
||||
|
||||
const evt: CalendarEvent = {
|
||||
let rawLocation = req.body.location
|
||||
|
||||
let evt: CalendarEvent = {
|
||||
type: selectedEventType.title,
|
||||
title: getEventName(req.body.name, selectedEventType.title, selectedEventType.eventName),
|
||||
description: req.body.notes,
|
||||
startTime: req.body.start,
|
||||
endTime: req.body.end,
|
||||
location: req.body.location,
|
||||
organizer: {email: currentUser.email, name: currentUser.name, timeZone: currentUser.timeZone},
|
||||
attendees: [
|
||||
{email: req.body.email, name: req.body.name, timeZone: req.body.timeZone}
|
||||
]
|
||||
};
|
||||
|
||||
// If phone or inPerson use raw location
|
||||
// set evt.location to req.body.location
|
||||
if (!rawLocation.includes('integration')) {
|
||||
evt.location = rawLocation
|
||||
}
|
||||
|
||||
|
||||
// If location is set to an integration location
|
||||
// Build proper transforms for evt object
|
||||
// Extend evt object with those transformations
|
||||
if (rawLocation.includes('integration')) {
|
||||
let maybeLocationRequestObject = getLocationRequestFromIntegration({
|
||||
location: rawLocation
|
||||
})
|
||||
|
||||
evt = merge(evt, maybeLocationRequestObject)
|
||||
}
|
||||
|
||||
const eventType = await prisma.eventType.findFirst({
|
||||
where: {
|
||||
userId: currentUser.id,
|
||||
|
||||
Reference in new issue
Block a user