fix: api v2 - platform users can disable emails and display their links (#14604)
* fix: disable emails with oauthCLient settings and hide empty links * fixup! fix: disable emails with oauthCLient settings and hide empty links * feat: enable to display booking success page link in emails * fixup! feat: enable to display booking success page link in emails * fixup! Merge branch 'fix-no-email-booking-hide-empty-links' of github.com:calcom/cal.com into fix-no-email-booking-hide-empty-links * fixup! fixup! Merge branch 'fix-no-email-booking-hide-empty-links' of github.com:calcom/cal.com into fix-no-email-booking-hide-empty-links * fixup! Merge branch 'main' into fix-no-email-booking-hide-empty-links * fixup! Merge branch 'main' into fix-no-email-booking-hide-empty-links * fixup! Merge branch 'fix-no-email-booking-hide-empty-links' of github.com:calcom/cal.com into fix-no-email-booking-hide-empty-links --------- Co-authored-by: Lauris Skraucis <[email protected]>
This commit is contained in:
1 parent
8b2e46a6fa
commit
480977c2b5
4 files changed
+84
-31
No files matched your search
@@ -58,6 +58,7 @@ type OAuthRequestParams = {
|
||||
platformCancelUrl: string;
|
||||
platformBookingUrl: string;
|
||||
platformBookingLocation?: string;
|
||||
arePlatformEmailsEnabled: boolean;
|
||||
};
|
||||
|
||||
const DEFAULT_PLATFORM_PARAMS = {
|
||||
@@ -65,7 +66,7 @@ const DEFAULT_PLATFORM_PARAMS = {
|
||||
platformCancelUrl: "",
|
||||
platformRescheduleUrl: "",
|
||||
platformBookingUrl: "",
|
||||
areEmailsEnabled: true,
|
||||
arePlatformEmailsEnabled: false,
|
||||
platformBookingLocation: undefined,
|
||||
};
|
||||
|
||||
@@ -172,6 +173,7 @@ export class BookingsController {
|
||||
const oAuthClientId = clientId?.toString();
|
||||
if (bookingId) {
|
||||
try {
|
||||
req.body.id = parseInt(bookingId);
|
||||
await handleCancelBooking(await this.createNextApiBookingRequest(req, oAuthClientId));
|
||||
return {
|
||||
status: SUCCESS_STATUS,
|
||||
@@ -239,10 +241,7 @@ export class BookingsController {
|
||||
}
|
||||
}
|
||||
|
||||
async getOAuthClientsParams(
|
||||
req: BookingRequest,
|
||||
clientId: string
|
||||
): Promise<OAuthRequestParams & { areEmailsEnabled: boolean }> {
|
||||
async getOAuthClientsParams(req: BookingRequest, clientId: string): Promise<OAuthRequestParams> {
|
||||
const res = DEFAULT_PLATFORM_PARAMS;
|
||||
try {
|
||||
const client = await this.oAuthClientRepository.getOAuthClient(clientId);
|
||||
@@ -252,7 +251,7 @@ export class BookingsController {
|
||||
res.platformCancelUrl = client.bookingCancelRedirectUri ?? "";
|
||||
res.platformRescheduleUrl = client.bookingRescheduleRedirectUri ?? "";
|
||||
res.platformBookingUrl = client.bookingRedirectUri ?? "";
|
||||
res.areEmailsEnabled = client.areEmailsEnabled;
|
||||
res.arePlatformEmailsEnabled = client.areEmailsEnabled ?? false;
|
||||
}
|
||||
return res;
|
||||
} catch (err) {
|
||||
@@ -271,7 +270,7 @@ export class BookingsController {
|
||||
? await this.getOAuthClientsParams(req, oAuthClientId)
|
||||
: DEFAULT_PLATFORM_PARAMS;
|
||||
Object.assign(req, { userId, ...oAuthParams, platformBookingLocation });
|
||||
req.body = { ...req.body, areEmailsEnabled: oAuthParams.areEmailsEnabled };
|
||||
req.body = { ...req.body, noEmail: !oAuthParams.arePlatformEmailsEnabled };
|
||||
return req as unknown as NextApiRequest & { userId?: number } & OAuthRequestParams;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user