-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* plain custom desin * No display on card * dynamic plain chat component and hmac hash * re-route users to plain.com chat instead of intercom chat when going to /support * provider errors * yarn lock fix * plain chat removed unneeded hmac * fix ts error * error handling improved * remove intercome provider from app-dir * Create getting-started.mdx (#18342) * Delete help directory (#18343) * chore: moved docs/help to /help (#18345) * chore: Delete unused guides directory (#18346) * feat: booking filters (#18303) Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> * chore: Remove `HeadSeo` components where no longer needed + improve app router metadata logic (#18348) * remove HeadSeo for already migrated pages and refactor prepareMetadata * create _generateMetadataWithoutImage and refactor _generateMetadata * chore: app router - /bookings status page (#18183) * chore: app router - /bookings page * remove env vars * fix * Update middleware.ts * revert unneeded change * refactor for the better * fix * cache i18n instances (#18309) * feat: virtual queues tab in insights (#18260) Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: sean-brydon <sean@cal.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Omar López <zomars@me.com> * feat: update translations via @replexica (#18361) Co-authored-by: Replexica <support@replexica.com> * update OOO e2e tests to remove flakiness (#18367) * fix: metadata is overwritten for child managed eventType when updating parent (#18059) * fix: metadata is overwirten * Update * type error * Update * fix test * fix type error * chore: added routing support link (#18369) * Added routing form support link * small change * Type fix --------- Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com> * chore: refactor handling logic for embeds in app router (#18362) * refactor handling logic for embeds in app router * fix type checks * add test for withEmbedSsrAppDir * fix * review changes * yarn lock --------- Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Calcom Bot <109866826+calcom-bot@users.noreply.github.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Co-authored-by: Benny Joo <sldisek783@gmail.com> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: sean-brydon <sean@cal.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Co-authored-by: Omar López <zomars@me.com> Co-authored-by: Replexica <support@replexica.com> Co-authored-by: Vijay <vijayraghav22@gmail.com> Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com> Co-authored-by: Alex van Andel <me@alexvanandel.com>
- Loading branch information
1 parent
3994929
commit 225313e
Showing
12 changed files
with
7,767 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { createHmac } from "crypto"; | ||
import { NextResponse } from "next/server"; | ||
import { z } from "zod"; | ||
|
||
import { getServerSession } from "@calcom/features/auth/lib/getServerSession"; | ||
import { apiRouteMiddleware } from "@calcom/lib/server/apiRouteMiddleware"; | ||
|
||
const responseSchema = z.object({ | ||
hash: z.string(), | ||
email: z.string().email(), | ||
shortName: z.string(), | ||
appId: z.string(), | ||
fullName: z.string(), | ||
chatAvatarUrl: z.string(), | ||
}); | ||
|
||
async function handler(request: Request) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const session = await getServerSession({ req: request as any }); | ||
if (!session?.user?.email) { | ||
return new Response("Unauthorized - No session email found", { status: 401 }); | ||
} | ||
|
||
const secret = process.env.PLAIN_CHAT_HMAC_SECRET_KEY; | ||
if (!secret) { | ||
return new Response("Missing Plain Chat secret", { status: 500 }); | ||
} | ||
|
||
const hmac = createHmac("sha256", secret); | ||
hmac.update(session.user.email.toLowerCase().trim()); | ||
const hash = hmac.digest("hex"); | ||
|
||
const shortName = | ||
(session.user.name?.split(" ")[0] || session.user.email).charAt(0).toUpperCase() + | ||
(session.user.name?.split(" ")[0] || session.user.email).slice(1) || "User"; | ||
|
||
const response = responseSchema.parse({ | ||
hash, | ||
email: session.user.email || "user@example.com", | ||
shortName, | ||
appId: process.env.PLAIN_CHAT_ID, | ||
fullName: session.user.name || "User", | ||
chatAvatarUrl: session.user.avatarUrl || "", | ||
}); | ||
|
||
return NextResponse.json(response); | ||
} | ||
|
||
export const POST = apiRouteMiddleware(handler); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.