Skip to content

Commit

Permalink
chore: Update EWS package (#16950)
Browse files Browse the repository at this point in the history
* Update ews package

* Hide exchange version if using NTLM

* Remove instance of gzip

* Update yarn.lock file

* Updated yarn.lock

* Update yarn.lock

* Update yarn.lock

* Update yarn.lock (again)

* chore: Increase readability of [number] indexes by using find

* chore: Async not needed

* fix: Move 'use client' to appropriate file

* refactor

* install deasync directly as dev dependency

* fix type error

---------

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: Benny Joo <sldisek783@gmail.com>
  • Loading branch information
5 people authored Oct 10, 2024
1 parent 99caae8 commit c8e8800
Show file tree
Hide file tree
Showing 11 changed files with 1,370 additions and 153 deletions.
2 changes: 1 addition & 1 deletion apps/web/app/future/apps/[slug]/[...pages]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { withAppDirSsr } from "app/WithAppDirSsr";
import { PageProps } from "app/_types";
import type { PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import type { GetServerSidePropsResult } from "next";
Expand Down
2 changes: 2 additions & 0 deletions apps/web/components/PageWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { DefaultSeo } from "next-seo";
import { Inter } from "next/font/google";
import localFont from "next/font/local";
Expand Down
17 changes: 7 additions & 10 deletions apps/web/lib/team/[slug]/[type]/getServerSideProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import type { RouterOutputs } from "@calcom/trpc";

import { getTemporaryOrgRedirect } from "@lib/getTemporaryOrgRedirect";

import { ssrInit } from "@server/lib/ssr";

const paramsSchema = z.object({
type: z.string().transform((s) => slugify(s)),
slug: z.string().transform((s) => slugify(s)),
Expand All @@ -23,17 +25,12 @@ const paramsSchema = z.object({
// 1. Check if team exists, to show 404
// 2. If rescheduling, get the booking details
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const session = await getServerSession(context);
const { slug: teamSlug, type: meetingSlug } = paramsSchema.parse(context.params);
const {
rescheduleUid,
duration: queryDuration,
isInstantMeeting: queryIsInstantMeeting,
email,
} = context.query;
const { ssrInit } = await import("@server/lib/ssr");
const { req, params, query } = context;
const session = await getServerSession({ req });
const { slug: teamSlug, type: meetingSlug } = paramsSchema.parse(params);
const { rescheduleUid, isInstantMeeting: queryIsInstantMeeting, email } = query;
const ssr = await ssrInit(context);
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(context.req, context.params?.orgSlug);
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(req, params?.orgSlug);
const isOrgContext = currentOrgDomain && isValidOrgDomain;

if (!isOrgContext) {
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
"@types/uuid": "8.3.1",
"autoprefixer": "^10.4.12",
"copy-webpack-plugin": "^11.0.0",
"deasync": "^0.1.30",
"detect-port": "^1.3.0",
"env-cmd": "^10.1.0",
"module-alias": "^2.2.2",
Expand Down
2 changes: 0 additions & 2 deletions apps/web/pages/org/[orgSlug]/[user]/[type]/embed.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use client";

import withEmbedSsr from "@lib/withEmbedSsr";

import { getServerSideProps as _getServerSideProps } from ".";
Expand Down
2 changes: 0 additions & 2 deletions apps/web/pages/org/[orgSlug]/[user]/[type]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use client";

import PageWrapper from "@components/PageWrapper";

import type { PageProps as TeamTypePageProps } from "~/team/type-view";
Expand Down
1 change: 0 additions & 1 deletion packages/app-store/exchangecalendar/lib/CalendarService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ export default class ExchangeCalendarService implements Calendar {
if (this.payload.authenticationMethod === ExchangeAuthentication.NTLM) {
const xhr: XhrApi = new XhrApi({
rejectUnauthorized: false,
gzip: this.payload.useCompression,
}).useNtlmAuthentication(this.payload.username, this.payload.password);
service.XHRApi = xhr;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/app-store/exchangecalendar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"@calcom/lib": "*",
"@calcom/prisma": "*",
"@ewsjs/xhr": "^1.4.4",
"@ewsjs/xhr": "^3.1.2",
"ews-javascript-api": "^0.11.0"
},
"devDependencies": {
Expand Down
82 changes: 44 additions & 38 deletions packages/app-store/exchangecalendar/pages/setup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Toaster } from "react-hot-toast";
import z from "zod";

import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Alert, Button, EmailField, Form, PasswordField, SelectField, Switch, TextField } from "@calcom/ui";
import { Alert, Button, EmailField, Form, PasswordField, SelectField, TextField } from "@calcom/ui";

import { ExchangeAuthentication, ExchangeVersion } from "../../enums";

Expand Down Expand Up @@ -36,11 +36,12 @@ export default function ExchangeSetup() {
const [errorMessage, setErrorMessage] = useState("");
const form = useForm<IFormData>({
defaultValues: {
authenticationMethod: ExchangeAuthentication.STANDARD,
authenticationMethod: ExchangeAuthentication.NTLM,
exchangeVersion: ExchangeVersion.Exchange2016,
},
resolver: zodResolver(schema),
});
const authenticationMethod = form.watch("authenticationMethod");
const authenticationMethods = [
{ value: ExchangeAuthentication.STANDARD, label: t("exchange_authentication_standard") },
{ value: ExchangeAuthentication.NTLM, label: t("exchange_authentication_ntlm") },
Expand Down Expand Up @@ -115,44 +116,49 @@ export default function ExchangeSetup() {
<Controller
name="authenticationMethod"
control={form.control}
render={({ field: { onChange } }) => (
<SelectField
label={t("exchange_authentication")}
options={authenticationMethods}
defaultValue={authenticationMethods[0]}
onChange={async (authentication) => {
if (authentication) {
onChange(authentication.value);
form.setValue("authenticationMethod", authentication.value);
}
}}
/>
)}
/>
<Controller
name="exchangeVersion"
control={form.control}
render={({ field: { onChange } }) => (
<SelectField
label={t("exchange_version")}
options={exchangeVersions}
defaultValue={exchangeVersions[7]}
onChange={async (version) => {
onChange(version?.value);
if (version) {
form.setValue("exchangeVersion", version.value);
}
}}
/>
)}
/>
<Switch
label={t("exchange_compression")}
name="useCompression"
onCheckedChange={async (alt) => {
form.setValue("useCompression", alt);
render={({ field: { onChange } }) => {
const ntlmAuthenticationMethod = authenticationMethods.find(
(method) => method.value === ExchangeAuthentication.NTLM
);
return (
<SelectField
label={t("exchange_authentication")}
options={authenticationMethods}
defaultValue={ntlmAuthenticationMethod}
onChange={(authentication) => {
if (authentication) {
onChange(authentication.value);
form.setValue("authenticationMethod", authentication.value);
}
}}
/>
);
}}
/>
{authenticationMethod === ExchangeAuthentication.STANDARD ? (
<Controller
name="exchangeVersion"
control={form.control}
render={({ field: { onChange } }) => {
const exchangeVersion2016 = exchangeVersions.find(
(exchangeVersion) => exchangeVersion.value === ExchangeVersion.Exchange2016
);
return (
<SelectField
label={t("exchange_version")}
options={exchangeVersions}
defaultValue={exchangeVersion2016}
onChange={(version) => {
onChange(version?.value);
if (version) {
form.setValue("exchangeVersion", version.value);
}
}}
/>
);
}}
/>
) : null}
</fieldset>
{errorMessage && <Alert severity="error" title={errorMessage} className="my-4" />}
<div className="mt-4 flex justify-end space-x-2 rtl:space-x-reverse">
Expand Down
111 changes: 56 additions & 55 deletions packages/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -570,60 +570,60 @@ enum BookingStatus {
}

model Booking {
id Int @id @default(autoincrement())
uid String @unique
id Int @id @default(autoincrement())
uid String @unique
// (optional) UID based on slot start/end time & email against duplicates
idempotencyKey String? @unique
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
userId Int?
idempotencyKey String? @unique
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
userId Int?
// User's email at the time of booking
/// @zod.email()
userPrimaryEmail String?
references BookingReference[]
eventType EventType? @relation(fields: [eventTypeId], references: [id])
eventTypeId Int?
title String
description String?
customInputs Json?
userPrimaryEmail String?
references BookingReference[]
eventType EventType? @relation(fields: [eventTypeId], references: [id])
eventTypeId Int?
title String
description String?
customInputs Json?
/// @zod.custom(imports.bookingResponses)
responses Json?
startTime DateTime
endTime DateTime
attendees Attendee[]
location String?
createdAt DateTime @default(now())
updatedAt DateTime?
status BookingStatus @default(ACCEPTED)
paid Boolean @default(false)
payment Payment[]
destinationCalendar DestinationCalendar? @relation(fields: [destinationCalendarId], references: [id])
destinationCalendarId Int?
cancellationReason String?
rejectionReason String?
dynamicEventSlugRef String?
dynamicGroupSlugRef String?
rescheduled Boolean?
fromReschedule String?
recurringEventId String?
smsReminderNumber String?
workflowReminders WorkflowReminder[]
scheduledJobs String[] // scheduledJobs is deprecated, please use scheduledTriggers instead
seatsReferences BookingSeat[]
responses Json?
startTime DateTime
endTime DateTime
attendees Attendee[]
location String?
createdAt DateTime @default(now())
updatedAt DateTime?
status BookingStatus @default(ACCEPTED)
paid Boolean @default(false)
payment Payment[]
destinationCalendar DestinationCalendar? @relation(fields: [destinationCalendarId], references: [id])
destinationCalendarId Int?
cancellationReason String?
rejectionReason String?
dynamicEventSlugRef String?
dynamicGroupSlugRef String?
rescheduled Boolean?
fromReschedule String?
recurringEventId String?
smsReminderNumber String?
workflowReminders WorkflowReminder[]
scheduledJobs String[] // scheduledJobs is deprecated, please use scheduledTriggers instead
seatsReferences BookingSeat[]
/// @zod.custom(imports.bookingMetadataSchema)
metadata Json?
isRecorded Boolean @default(false)
iCalUID String? @default("")
iCalSequence Int @default(0)
instantMeetingToken InstantMeetingToken?
rating Int?
ratingFeedback String?
noShowHost Boolean? @default(false)
scheduledTriggers WebhookScheduledTriggers[]
oneTimePassword String? @unique @default(uuid())
metadata Json?
isRecorded Boolean @default(false)
iCalUID String? @default("")
iCalSequence Int @default(0)
instantMeetingToken InstantMeetingToken?
rating Int?
ratingFeedback String?
noShowHost Boolean? @default(false)
scheduledTriggers WebhookScheduledTriggers[]
oneTimePassword String? @unique @default(uuid())
/// @zod.email()
cancelledBy String?
cancelledBy String?
/// @zod.email()
rescheduledBy String?
rescheduledBy String?
routedFromRoutingFormReponse App_RoutingForms_FormResponse?
@@index([eventTypeId])
Expand Down Expand Up @@ -935,15 +935,16 @@ model App_RoutingForms_Form {
}

model App_RoutingForms_FormResponse {
id Int @id @default(autoincrement())
formFillerId String @default(cuid())
form App_RoutingForms_Form @relation(fields: [formId], references: [id], onDelete: Cascade)
formId String
response Json
createdAt DateTime @default(now())
routedToBookingUid String? @unique
id Int @id @default(autoincrement())
formFillerId String @default(cuid())
form App_RoutingForms_Form @relation(fields: [formId], references: [id], onDelete: Cascade)
formId String
response Json
createdAt DateTime @default(now())
routedToBookingUid String? @unique
// We should not cascade delete the booking, because we want to keep the form response even if the routedToBooking is deleted
routedToBooking Booking? @relation(fields: [routedToBookingUid], references: [uid])
routedToBooking Booking? @relation(fields: [routedToBookingUid], references: [uid])
@@unique([formFillerId, formId])
@@index([formFillerId])
@@index([formId])
Expand Down
Loading

0 comments on commit c8e8800

Please sign in to comment.