chore: rename DWD to DelegationCredential (#19703)
* chore: rename DWD to DelegationCredential * fixup! chore: rename DWD to DelegationCredential * fixup! fixup! chore: rename DWD to DelegationCredential * fixup! Merge branch 'main' into rename-domain-wide-delegation * fixup! fixup! Merge branch 'main' into rename-domain-wide-delegation * fixup! fixup! fixup! Merge branch 'main' into rename-domain-wide-delegation
This commit is contained in:
1 parent
a39b5e47a7
commit
7a9ddf2194
167 files changed
+4232
-2356
No files matched your search
@@ -12,7 +12,7 @@ import type {
|
||||
EventTypes,
|
||||
} from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
|
||||
import { BulkEditDefaultForEventsModal } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
|
||||
import { isDwdCredential } from "@calcom/lib/domainWideDelegation/clientAndServer";
|
||||
import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { AppCategories } from "@calcom/prisma/enums";
|
||||
import { type RouterOutputs } from "@calcom/trpc";
|
||||
@@ -230,7 +230,7 @@ function ConnectOrDisconnectIntegrationMenuItem(props: {
|
||||
<DropdownItem
|
||||
color="destructive"
|
||||
onClick={() => handleDisconnect(credentialId, app, teamId)}
|
||||
disabled={isGlobal || isDwdCredential({ credentialId })}
|
||||
disabled={isGlobal || isDelegationCredential({ credentialId })}
|
||||
StartIcon="trash">
|
||||
{t("remove_app")}
|
||||
</DropdownItem>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
import { isDwdCredential } from "@calcom/lib/domainWideDelegation/clientAndServer";
|
||||
import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { ButtonProps } from "@calcom/ui";
|
||||
@@ -38,8 +38,8 @@ export default function DisconnectIntegration(props: {
|
||||
},
|
||||
});
|
||||
|
||||
// Such a credential is added in-memory and removed when Domain-wide delegation is disabled.
|
||||
const disableDisconnect = isDwdCredential({ credentialId });
|
||||
// Such a credential is added in-memory and removed when Delegation credential is disabled.
|
||||
const disableDisconnect = isDelegationCredential({ credentialId });
|
||||
return (
|
||||
<DisconnectIntegrationComponent
|
||||
onDeletionConfirmation={() => mutation.mutate({ id: credentialId, ...(teamId ? { teamId } : {}) })}
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import type z from "zod";
|
||||
|
||||
import { enrichUserWithDwdCredentialsWithoutOrgId } from "@calcom/lib/domainWideDelegation/server";
|
||||
import { enrichUserWithDelegationCredentialsWithoutOrgId } from "@calcom/lib/delegationCredential/server";
|
||||
import { UserRepository } from "@calcom/lib/server/repository/user";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
|
||||
@@ -120,9 +120,9 @@ export const getAllCredentials = async (
|
||||
}
|
||||
});
|
||||
|
||||
const userWithDwdCredentials = await enrichUserWithDwdCredentialsWithoutOrgId({
|
||||
const userWithDelegationCredentials = await enrichUserWithDelegationCredentialsWithoutOrgId({
|
||||
user: { ...user, credentials: allCredentials },
|
||||
});
|
||||
|
||||
return userWithDwdCredentials.credentials;
|
||||
return userWithDelegationCredentials.credentials;
|
||||
};
|
||||
+10
-6
@@ -1,7 +1,7 @@
|
||||
import async from "async";
|
||||
|
||||
import { isDwdCredential } from "@calcom/lib/domainWideDelegation/clientAndServer";
|
||||
import { buildAllCredentials } from "@calcom/lib/domainWideDelegation/server";
|
||||
import { isDelegationCredential } from "@calcom/lib/delegationCredential/clientAndServer";
|
||||
import { buildAllCredentials } from "@calcom/lib/delegationCredential/server";
|
||||
import type { CredentialForCalendarService } from "@calcom/types/Credential";
|
||||
|
||||
import { refreshCredential } from "./refreshCredential";
|
||||
@@ -14,8 +14,12 @@ import { refreshCredential } from "./refreshCredential";
|
||||
export async function refreshCredentials(
|
||||
credentials: Array<CredentialForCalendarService>
|
||||
): Promise<Array<CredentialForCalendarService>> {
|
||||
const nonDwdCredentials = credentials.filter((cred) => !isDwdCredential({ credentialId: cred.id }));
|
||||
const dwdCredentials = credentials.filter((cred) => isDwdCredential({ credentialId: cred.id }));
|
||||
const refreshedDbCredentials = await async.mapLimit(nonDwdCredentials, 5, refreshCredential);
|
||||
return buildAllCredentials({ dwdCredentials, existingCredentials: refreshedDbCredentials });
|
||||
const nonDelegationCredentials = credentials.filter(
|
||||
(cred) => !isDelegationCredential({ credentialId: cred.id })
|
||||
);
|
||||
const delegationCredentials = credentials.filter((cred) =>
|
||||
isDelegationCredential({ credentialId: cred.id })
|
||||
);
|
||||
const refreshedDbCredentials = await async.mapLimit(nonDelegationCredentials, 5, refreshCredential);
|
||||
return buildAllCredentials({ delegationCredentials, existingCredentials: refreshedDbCredentials });
|
||||
}
|
||||
@@ -70,7 +70,7 @@ async function getBookingToDelete(id: number | undefined, uid: string | undefine
|
||||
externalCalendarId: true,
|
||||
credentialId: true,
|
||||
thirdPartyRecurringEventId: true,
|
||||
domainWideDelegationCredentialId: true,
|
||||
delegationCredentialId: true,
|
||||
},
|
||||
},
|
||||
payment: true,
|
||||
|
||||
@@ -48,9 +48,9 @@ import EventManager from "@calcom/lib/EventManager";
|
||||
import { shouldIgnoreContactOwner } from "@calcom/lib/bookings/routing/utils";
|
||||
import { getDefaultEvent, getUsernameList } from "@calcom/lib/defaultEvents";
|
||||
import {
|
||||
enrichHostsWithDwdCredentials,
|
||||
getFirstDwdConferencingCredentialAppLocation,
|
||||
} from "@calcom/lib/domainWideDelegation/server";
|
||||
enrichHostsWithDelegationCredentials,
|
||||
getFirstDelegationConferencingCredentialAppLocation,
|
||||
} from "@calcom/lib/delegationCredential/server";
|
||||
import { ErrorCode } from "@calcom/lib/errorCodes";
|
||||
import { getErrorFromUnknown } from "@calcom/lib/errors";
|
||||
import { getEventName } from "@calcom/lib/event";
|
||||
@@ -690,7 +690,7 @@ async function handler(
|
||||
// find a lucky user that is not already in the luckyUsers array
|
||||
availableUsers: freeUsers,
|
||||
allRRHosts: (
|
||||
await enrichHostsWithDwdCredentials({
|
||||
await enrichHostsWithDelegationCredentials({
|
||||
orgId: firstUserOrgId ?? null,
|
||||
hosts: eventTypeWithUsers.hosts,
|
||||
})
|
||||
@@ -809,7 +809,7 @@ async function handler(
|
||||
}
|
||||
}
|
||||
|
||||
const organizationDefaultLocation = getFirstDwdConferencingCredentialAppLocation({
|
||||
const organizationDefaultLocation = getFirstDelegationConferencingCredentialAppLocation({
|
||||
credentials: firstUser.credentials,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getFirstDwdConferencingCredentialAppLocation } from "@calcom/lib/domainWideDelegation/server";
|
||||
import { getFirstDelegationConferencingCredentialAppLocation } from "@calcom/lib/delegationCredential/server";
|
||||
import type { Prisma } from "@calcom/prisma/client";
|
||||
import { userMetadata as userMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
import type { CredentialForCalendarService } from "@calcom/types/Credential";
|
||||
@@ -36,13 +36,14 @@ export const getLocationValuesForDb = <
|
||||
users = sortUsersByDynamicList(users, dynamicUserList);
|
||||
const firstDynamicGroupMember = users[0];
|
||||
const firstDynamicGroupMemberMetadata = userMetadataSchema.parse(firstDynamicGroupMember.metadata);
|
||||
const firstDynamicGroupMemberDwdConferencingAppLocation = getFirstDwdConferencingCredentialAppLocation({
|
||||
credentials: firstDynamicGroupMember.credentials,
|
||||
});
|
||||
const firstDynamicGroupMemberDelegationCredentialConferencingAppLocation =
|
||||
getFirstDelegationConferencingCredentialAppLocation({
|
||||
credentials: firstDynamicGroupMember.credentials,
|
||||
});
|
||||
|
||||
firstDynamicGroupMemberDefaultLocationUrl =
|
||||
firstDynamicGroupMemberMetadata?.defaultConferencingApp?.appLink ||
|
||||
firstDynamicGroupMemberDwdConferencingAppLocation;
|
||||
firstDynamicGroupMemberDelegationCredentialConferencingAppLocation;
|
||||
|
||||
locationBodyString = firstDynamicGroupMemberDefaultLocationUrl || locationBodyString;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ import type { Prisma } from "@prisma/client";
|
||||
import type { IncomingMessage } from "http";
|
||||
import type { Logger } from "tslog";
|
||||
|
||||
import { findQualifiedHostsWithDwdCredentials } from "@calcom/lib/bookings/findQualifiedHostsWithDwdCredentials";
|
||||
import { enrichUsersWithDwdCredentials } from "@calcom/lib/domainWideDelegation/server";
|
||||
import { findQualifiedHostsWithDelegationCredentials } from "@calcom/lib/bookings/findQualifiedHostsWithDelegationCredentials";
|
||||
import { enrichUsersWithDelegationCredentials } from "@calcom/lib/delegationCredential/server";
|
||||
import getOrgIdFromMemberOrTeamId from "@calcom/lib/getOrgIdFromMemberOrTeamId";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
import { getPiiFreeUser } from "@calcom/lib/piiFreeData";
|
||||
@@ -25,7 +25,10 @@ type Users = (Awaited<ReturnType<typeof loadUsers>>[number] & {
|
||||
createdAt?: Date;
|
||||
})[];
|
||||
|
||||
export type UsersWithDwdCredentials = (Omit<Awaited<ReturnType<typeof loadUsers>>[number], "credentials"> & {
|
||||
export type UsersWithDelegationCredentials = (Omit<
|
||||
Awaited<ReturnType<typeof loadUsers>>[number],
|
||||
"credentials"
|
||||
> & {
|
||||
isFixed?: boolean;
|
||||
metadata?: Prisma.JsonValue;
|
||||
createdAt?: Date;
|
||||
@@ -72,9 +75,9 @@ export async function loadAndValidateUsers({
|
||||
rescheduleUid,
|
||||
routingFormResponse,
|
||||
}: InputProps): Promise<{
|
||||
qualifiedRRUsers: UsersWithDwdCredentials;
|
||||
additionalFallbackRRUsers: UsersWithDwdCredentials;
|
||||
fixedUsers: UsersWithDwdCredentials;
|
||||
qualifiedRRUsers: UsersWithDelegationCredentials;
|
||||
additionalFallbackRRUsers: UsersWithDelegationCredentials;
|
||||
fixedUsers: UsersWithDelegationCredentials;
|
||||
}> {
|
||||
let users: Users = await loadUsers({
|
||||
eventType,
|
||||
@@ -125,13 +128,14 @@ export async function loadAndValidateUsers({
|
||||
? false
|
||||
: user.isFixed || eventType.schedulingType !== SchedulingType.ROUND_ROBIN,
|
||||
}));
|
||||
const { qualifiedRRHosts, allFallbackRRHosts, fixedHosts } = await findQualifiedHostsWithDwdCredentials({
|
||||
eventType,
|
||||
routedTeamMemberIds: routedTeamMemberIds || [],
|
||||
rescheduleUid,
|
||||
contactOwnerEmail,
|
||||
routingFormResponse,
|
||||
});
|
||||
const { qualifiedRRHosts, allFallbackRRHosts, fixedHosts } =
|
||||
await findQualifiedHostsWithDelegationCredentials({
|
||||
eventType,
|
||||
routedTeamMemberIds: routedTeamMemberIds || [],
|
||||
rescheduleUid,
|
||||
contactOwnerEmail,
|
||||
routingFormResponse,
|
||||
});
|
||||
const allQualifiedHostsHashMap = [...qualifiedRRHosts, ...(allFallbackRRHosts ?? []), ...fixedHosts].reduce(
|
||||
(acc, host) => {
|
||||
if (host.user.id) {
|
||||
@@ -141,14 +145,14 @@ export async function loadAndValidateUsers({
|
||||
},
|
||||
{} as {
|
||||
[key: number]: Awaited<
|
||||
ReturnType<typeof findQualifiedHostsWithDwdCredentials>
|
||||
ReturnType<typeof findQualifiedHostsWithDelegationCredentials>
|
||||
>["qualifiedRRHosts"][number];
|
||||
}
|
||||
);
|
||||
|
||||
let qualifiedRRUsers: UsersWithDwdCredentials = [];
|
||||
let allFallbackRRUsers: UsersWithDwdCredentials = [];
|
||||
let fixedUsers: UsersWithDwdCredentials = [];
|
||||
let qualifiedRRUsers: UsersWithDelegationCredentials = [];
|
||||
let allFallbackRRUsers: UsersWithDelegationCredentials = [];
|
||||
let fixedUsers: UsersWithDelegationCredentials = [];
|
||||
|
||||
if (qualifiedRRHosts.length) {
|
||||
// remove users that are not in the qualified hosts array
|
||||
@@ -189,14 +193,14 @@ export async function loadAndValidateUsers({
|
||||
memberId: firstUser.id ?? null,
|
||||
teamId: eventType.teamId,
|
||||
});
|
||||
const usersEnrichedWithDwd = await enrichUsersWithDwdCredentials({
|
||||
const usersEnrichedWithDelegationCredential = await enrichUsersWithDelegationCredentials({
|
||||
orgId: firstUserOrgId ?? null,
|
||||
users,
|
||||
});
|
||||
return {
|
||||
qualifiedRRUsers,
|
||||
additionalFallbackRRUsers, // without qualified
|
||||
fixedUsers: usersEnrichedWithDwd,
|
||||
fixedUsers: usersEnrichedWithDelegationCredential,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+32
-28
@@ -17,9 +17,9 @@ import {
|
||||
mockSuccessfulVideoMeetingCreation,
|
||||
mockCalendarToHaveNoBusySlots,
|
||||
BookingLocations,
|
||||
createDwdCredential,
|
||||
createDelegationCredential,
|
||||
createOrganization,
|
||||
buildDwdCredential,
|
||||
buildDelegationCredential,
|
||||
} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
|
||||
import { createMockNextJsRequest } from "@calcom/web/test/utils/bookingScenario/createMockNextJsRequest";
|
||||
import {
|
||||
@@ -50,11 +50,11 @@ const timeout = process.env.CI ? 5000 : 20000;
|
||||
|
||||
describe("handleNewBooking", () => {
|
||||
setupAndTeardown();
|
||||
describe("Domain Wide Delegation", () => {
|
||||
describe("Delegation Credential", () => {
|
||||
test(
|
||||
`should create a successful booking using the domain wide delegation credential
|
||||
1. Should create a booking in the database with reference having DWD credential
|
||||
2. Should create an event in calendar with DWD credential
|
||||
`should create a successful booking using the delegation credential
|
||||
1. Should create a booking in the database with reference having Delegation credential
|
||||
2. Should create an event in calendar with Delegation credential
|
||||
3. Should use Google Meet as the location even when not explicitly set.
|
||||
`,
|
||||
async ({ emails }) => {
|
||||
@@ -90,14 +90,14 @@ describe("handleNewBooking", () => {
|
||||
id: 101,
|
||||
schedules: [TestData.schedules.IstWorkHours],
|
||||
selectedCalendars: [TestData.selectedCalendars.google],
|
||||
// User must be part of organization to be able to use that organization's DWD credential
|
||||
// User must be part of organization to be able to use that organization's Delegation credential
|
||||
teams: payloadToMakePartOfOrganization,
|
||||
// No regular credentials provided
|
||||
credentials: [],
|
||||
destinationCalendar: TestData.selectedCalendars.google,
|
||||
});
|
||||
|
||||
const dwd = await createDwdCredential(org.id);
|
||||
const delegationCredential = await createDelegationCredential(org.id);
|
||||
const payloadToCreateUserEventTypeForOrganizer = {
|
||||
id: 1,
|
||||
slotInterval: 30,
|
||||
@@ -193,8 +193,8 @@ describe("handleNewBooking", () => {
|
||||
meetingId: "GOOGLE_CALENDAR_EVENT_ID",
|
||||
meetingPassword: "MOCK_PASSWORD",
|
||||
meetingUrl: "https://GOOGLE_MEET_URL_IN_CALENDAR_EVENT",
|
||||
// Verify DWD credential was used
|
||||
domainWideDelegationCredentialId: dwd.id,
|
||||
// Verify Delegation credential was used
|
||||
delegationCredentialId: delegationCredential.id,
|
||||
},
|
||||
],
|
||||
iCalUID: createdBooking.iCalUID,
|
||||
@@ -202,7 +202,9 @@ describe("handleNewBooking", () => {
|
||||
|
||||
expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails });
|
||||
expectSuccessfulCalendarEventCreationInCalendar(calendarMock, {
|
||||
credential: buildDwdCredential({ serviceAccountKey: dwd.serviceAccountKey }),
|
||||
credential: buildDelegationCredential({
|
||||
serviceAccountKey: delegationCredential.serviceAccountKey,
|
||||
}),
|
||||
calendarId: TestData.selectedCalendars.google.externalId,
|
||||
// There would be no videoCallUrl in this case as it is not a dedicated conferencing case and hangoutLink is used instead
|
||||
videoCallUrl: null,
|
||||
@@ -232,9 +234,9 @@ describe("handleNewBooking", () => {
|
||||
);
|
||||
|
||||
test(
|
||||
`should create a successful booking using the office365 domain wide delegation credential with Cal Video as the location
|
||||
1. Should create a booking in the database with reference having DWD credential
|
||||
2. Should create an event in Outlook calendar with DWD credential
|
||||
`should create a successful booking using the office365 delegation credential with Cal Video as the location
|
||||
1. Should create a booking in the database with reference having Delegation credential
|
||||
2. Should create an event in Outlook calendar with Delegation credential
|
||||
`,
|
||||
async ({ emails }) => {
|
||||
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
|
||||
@@ -269,14 +271,14 @@ describe("handleNewBooking", () => {
|
||||
id: 101,
|
||||
schedules: [TestData.schedules.IstWorkHours],
|
||||
selectedCalendars: [TestData.selectedCalendars.office365],
|
||||
// User must be part of organization to be able to use that organization's DWD credential
|
||||
// User must be part of organization to be able to use that organization's Delegation credential
|
||||
teams: payloadToMakePartOfOrganization,
|
||||
// No regular credentials provided
|
||||
credentials: [],
|
||||
destinationCalendar: TestData.selectedCalendars.office365,
|
||||
});
|
||||
|
||||
const dwd = await createDwdCredential(org.id, "office365");
|
||||
const delegationCredential = await createDelegationCredential(org.id, "office365");
|
||||
const payloadToCreateUserEventTypeForOrganizer = {
|
||||
id: 1,
|
||||
slotInterval: 30,
|
||||
@@ -390,8 +392,8 @@ describe("handleNewBooking", () => {
|
||||
meetingId: "OFFICE_365_CALENDAR_EVENT_ID",
|
||||
meetingPassword: "MOCK_PASSWORD",
|
||||
meetingUrl: "https://UNUSED_URL",
|
||||
// Verify DWD credential was used
|
||||
domainWideDelegationCredentialId: dwd.id,
|
||||
// Verify Delegation credential was used
|
||||
delegationCredentialId: delegationCredential.id,
|
||||
},
|
||||
],
|
||||
iCalUID: createdBooking.iCalUID,
|
||||
@@ -399,7 +401,9 @@ describe("handleNewBooking", () => {
|
||||
|
||||
expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails });
|
||||
expectSuccessfulCalendarEventCreationInCalendar(calendarMock, {
|
||||
credential: buildDwdCredential({ serviceAccountKey: dwd.serviceAccountKey }),
|
||||
credential: buildDelegationCredential({
|
||||
serviceAccountKey: delegationCredential.serviceAccountKey,
|
||||
}),
|
||||
calendarId: TestData.selectedCalendars.office365.externalId,
|
||||
// There would be no videoCallUrl in this case as it is not a dedicated conferencing case and hangoutLink is used instead
|
||||
videoCallUrl: null,
|
||||
@@ -430,7 +434,7 @@ describe("handleNewBooking", () => {
|
||||
);
|
||||
|
||||
test(
|
||||
`should fail calendar event creation when organizer isn't part of the organization of DWD Credential`,
|
||||
`should fail calendar event creation when organizer isn't part of the organization of DelegationCredential Credential`,
|
||||
async () => {
|
||||
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
|
||||
|
||||
@@ -470,13 +474,13 @@ describe("handleNewBooking", () => {
|
||||
id: 101,
|
||||
schedules: [TestData.schedules.IstWorkHours],
|
||||
selectedCalendars: [TestData.selectedCalendars.google],
|
||||
// User must be part of organization to be able to use that organization's DWD credential
|
||||
// User must be part of organization to be able to use that organization's Delegation credential
|
||||
teams: payloadToMakePartOfOrganization,
|
||||
// No regular credentials provided
|
||||
credentials: [],
|
||||
});
|
||||
|
||||
await createDwdCredential(anotherOrg.id);
|
||||
await createDelegationCredential(anotherOrg.id);
|
||||
const payloadToCreateUserEventTypeForOrganizer = {
|
||||
id: 1,
|
||||
slotInterval: 30,
|
||||
@@ -598,9 +602,9 @@ describe("handleNewBooking", () => {
|
||||
);
|
||||
|
||||
test(
|
||||
`should create a successful dynamic group booking using the domain wide delegation credential
|
||||
1. Should create a booking in the database with reference having DWD credential
|
||||
2. Should create an event in calendar with DWD credential for both users
|
||||
`should create a successful dynamic group booking using the delegation credential
|
||||
1. Should create a booking in the database with reference having Delegation credential
|
||||
2. Should create an event in calendar with Delegation credential for both users
|
||||
3. Should use Google Meet as the location even when not explicitly set.
|
||||
`,
|
||||
async () => {
|
||||
@@ -654,7 +658,7 @@ describe("handleNewBooking", () => {
|
||||
destinationCalendar: TestData.selectedCalendars.google,
|
||||
});
|
||||
|
||||
const dwd = await createDwdCredential(org.id);
|
||||
const delegationCredential = await createDelegationCredential(org.id);
|
||||
|
||||
await createBookingScenario(
|
||||
getScenarioData({
|
||||
@@ -747,8 +751,8 @@ describe("handleNewBooking", () => {
|
||||
meetingId: "GOOGLE_CALENDAR_EVENT_ID",
|
||||
meetingPassword: "MOCK_PASSWORD",
|
||||
meetingUrl: "https://GOOGLE_MEET_URL_IN_CALENDAR_EVENT",
|
||||
// Verify DWD credential was used
|
||||
domainWideDelegationCredentialId: dwd.id,
|
||||
// Verify Delegation credential was used
|
||||
delegationCredentialId: delegationCredential.id,
|
||||
},
|
||||
],
|
||||
iCalUID: createdBooking.iCalUID,
|
||||
@@ -4,8 +4,8 @@ import { getCalendar } from "@calcom/app-store/_utils/getCalendar";
|
||||
import { sendCancelledSeatEmailsAndSMS } from "@calcom/emails";
|
||||
import sendPayload from "@calcom/features/webhooks/lib/sendOrSchedulePayload";
|
||||
import type { EventPayloadType, EventTypeInfo } from "@calcom/features/webhooks/lib/sendPayload";
|
||||
import { getAllDwdCredentialsForUser } from "@calcom/lib/domainWideDelegation/server";
|
||||
import { getDwdOrFindRegularCredential } from "@calcom/lib/domainWideDelegation/server";
|
||||
import { getAllDelegationCredentialsForUser } from "@calcom/lib/delegationCredential/server";
|
||||
import { getDelegationCredentialOrFindRegularCredential } from "@calcom/lib/delegationCredential/server";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
@@ -69,8 +69,8 @@ async function cancelAttendeeSeat(
|
||||
|
||||
const attendee = bookingToDelete?.attendees.find((attendee) => attendee.id === seatReference.attendeeId);
|
||||
const bookingToDeleteUser = bookingToDelete.user ?? null;
|
||||
const dwdCredentials = bookingToDeleteUser
|
||||
? await getAllDwdCredentialsForUser({
|
||||
const delegationCredentials = bookingToDeleteUser
|
||||
? await getAllDelegationCredentialsForUser({
|
||||
user: { email: bookingToDeleteUser.email, id: bookingToDeleteUser.id },
|
||||
})
|
||||
: [];
|
||||
@@ -81,13 +81,13 @@ async function cancelAttendeeSeat(
|
||||
const integrationsToUpdate = [];
|
||||
|
||||
for (const reference of bookingToDelete.references) {
|
||||
if (reference.credentialId || reference.domainWideDelegationCredentialId) {
|
||||
const credential = await getDwdOrFindRegularCredential({
|
||||
if (reference.credentialId || reference.delegationCredentialId) {
|
||||
const credential = await getDelegationCredentialOrFindRegularCredential({
|
||||
id: {
|
||||
credentialId: reference.credentialId,
|
||||
domainWideDelegationCredentialId: reference.domainWideDelegationCredentialId,
|
||||
delegationCredentialId: reference.delegationCredentialId,
|
||||
},
|
||||
dwdCredentials,
|
||||
delegationCredentials,
|
||||
});
|
||||
|
||||
if (credential) {
|
||||
|
||||
@@ -2,8 +2,8 @@ import type { Attendee } from "@prisma/client";
|
||||
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { getCalendar } from "@calcom/app-store/_utils/getCalendar";
|
||||
import { getAllDwdCredentialsForUser } from "@calcom/lib/domainWideDelegation/server";
|
||||
import { getDwdOrFindRegularCredential } from "@calcom/lib/domainWideDelegation/server";
|
||||
import { getAllDelegationCredentialsForUser } from "@calcom/lib/delegationCredential/server";
|
||||
import { getDelegationCredentialOrFindRegularCredential } from "@calcom/lib/delegationCredential/server";
|
||||
import { deleteMeeting } from "@calcom/lib/videoClient";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { BookingStatus } from "@calcom/prisma/enums";
|
||||
@@ -20,8 +20,8 @@ const lastAttendeeDeleteBooking = async (
|
||||
) => {
|
||||
let deletedReferences = false;
|
||||
const bookingUser = originalRescheduledBooking?.user;
|
||||
const dwdCredentials = bookingUser
|
||||
? await getAllDwdCredentialsForUser({
|
||||
const delegationCredentials = bookingUser
|
||||
? await getAllDelegationCredentialsForUser({
|
||||
user: { email: bookingUser.email, id: bookingUser.id },
|
||||
})
|
||||
: [];
|
||||
@@ -29,13 +29,13 @@ const lastAttendeeDeleteBooking = async (
|
||||
const integrationsToDelete = [];
|
||||
|
||||
for (const reference of originalRescheduledBooking.references) {
|
||||
if (reference.credentialId || reference.domainWideDelegationCredentialId) {
|
||||
const credential = await getDwdOrFindRegularCredential({
|
||||
if (reference.credentialId || reference.delegationCredentialId) {
|
||||
const credential = await getDelegationCredentialOrFindRegularCredential({
|
||||
id: {
|
||||
credentialId: reference.credentialId,
|
||||
domainWideDelegationCredentialId: reference.domainWideDelegationCredentialId,
|
||||
delegationCredentialId: reference.delegationCredentialId,
|
||||
},
|
||||
dwdCredentials,
|
||||
delegationCredentials,
|
||||
});
|
||||
|
||||
if (credential) {
|
||||
|
||||
@@ -17,7 +17,7 @@ export type ICalendarSwitchProps = {
|
||||
isLastItemInList?: boolean;
|
||||
destination?: boolean;
|
||||
credentialId: number;
|
||||
domainWideDelegationCredentialId: string | null;
|
||||
delegationCredentialId: string | null;
|
||||
eventTypeId: number | null;
|
||||
disabled?: boolean;
|
||||
};
|
||||
@@ -36,7 +36,7 @@ const CalendarSwitch = (props: ICalendarSwitchProps) => {
|
||||
isChecked,
|
||||
name,
|
||||
credentialId,
|
||||
domainWideDelegationCredentialId,
|
||||
delegationCredentialId,
|
||||
eventTypeId,
|
||||
disabled,
|
||||
} = props;
|
||||
@@ -48,7 +48,7 @@ const CalendarSwitch = (props: ICalendarSwitchProps) => {
|
||||
const body = {
|
||||
integration: type,
|
||||
externalId: externalId,
|
||||
...(domainWideDelegationCredentialId && { domainWideDelegationCredentialId }),
|
||||
...(delegationCredentialId && { delegationCredentialId }),
|
||||
// new URLSearchParams does not accept numbers
|
||||
credentialId: String(credentialId),
|
||||
...(eventTypeId ? { eventTypeId: String(eventTypeId) } : {}),
|
||||
|
||||
@@ -7,7 +7,7 @@ import { sendCancelledEmailsAndSMS } from "@calcom/emails";
|
||||
import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";
|
||||
import { deleteWebhookScheduledTriggers } from "@calcom/features/webhooks/lib/scheduleTrigger";
|
||||
import { isPrismaObjOrUndefined, parseRecurringEvent } from "@calcom/lib";
|
||||
import { buildNonDwdCredential } from "@calcom/lib/domainWideDelegation/server";
|
||||
import { buildNonDelegationCredential } from "@calcom/lib/delegationCredential/server";
|
||||
import { DailyLocationType } from "@calcom/lib/location";
|
||||
import { deletePayment } from "@calcom/lib/payment/deletePayment";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
@@ -430,7 +430,7 @@ const handleDeleteCredential = async ({
|
||||
// If it's a calendar remove it from the SelectedCalendars
|
||||
if (credential.app?.categories.includes(AppCategories.calendar)) {
|
||||
try {
|
||||
const calendar = await getCalendar(buildNonDwdCredential(credential));
|
||||
const calendar = await getCalendar(buildNonDelegationCredential(credential));
|
||||
|
||||
const calendars = await calendar?.listCalendars();
|
||||
|
||||
|
||||
+19
-19
@@ -186,7 +186,7 @@ function CreateDelegationDialog({
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent enableOverflow title={t("add_domain_wide_delegation")}>
|
||||
<DialogContent enableOverflow title={t("add_delegation_credential")}>
|
||||
<Form form={form} handleSubmit={handleSubmit}>
|
||||
<DelegationFormFields workspacePlatforms={workspacePlatforms} isCreate={true} />
|
||||
<DialogFooter>
|
||||
@@ -226,7 +226,7 @@ function EditDelegationDialog({
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent title={t("edit_domain_wide_delegation")}>
|
||||
<DialogContent title={t("edit_delegation_credential")}>
|
||||
<Form form={form} handleSubmit={handleEdit}>
|
||||
<DelegationFormFields workspacePlatforms={workspacePlatforms} isCreate={false} />
|
||||
<DialogFooter>
|
||||
@@ -282,26 +282,26 @@ function DelegationFormFields({
|
||||
);
|
||||
}
|
||||
|
||||
function DomainWideDelegationList() {
|
||||
function DelegationCredentialList() {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useContext();
|
||||
const { data: delegations, isLoading, error } = trpc.viewer.domainWideDelegation.list.useQuery();
|
||||
const { data: delegations, isLoading, error } = trpc.viewer.delegationCredential.list.useQuery();
|
||||
|
||||
const updateMutation = trpc.viewer.domainWideDelegation.update.useMutation({
|
||||
onSuccess: () => utils.viewer.domainWideDelegation.list.invalidate(),
|
||||
const updateMutation = trpc.viewer.delegationCredential.update.useMutation({
|
||||
onSuccess: () => utils.viewer.delegationCredential.list.invalidate(),
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const toggleEnabledMutation = trpc.viewer.domainWideDelegation.toggleEnabled.useMutation({
|
||||
const toggleEnabledMutation = trpc.viewer.delegationCredential.toggleEnabled.useMutation({
|
||||
onSuccess: (data) => {
|
||||
if (data) {
|
||||
showToast(
|
||||
data.enabled ? t("domain_wide_delegation_enabled") : t("domain_wide_delegation_disabled"),
|
||||
data.enabled ? t("delegation_credential_enabled") : t("delegation_credential_disabled"),
|
||||
"success"
|
||||
);
|
||||
utils.viewer.domainWideDelegation.list.invalidate();
|
||||
utils.viewer.delegationCredential.list.invalidate();
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
@@ -309,15 +309,15 @@ function DomainWideDelegationList() {
|
||||
},
|
||||
});
|
||||
|
||||
const createMutation = trpc.viewer.domainWideDelegation.add.useMutation({
|
||||
onSuccess: () => utils.viewer.domainWideDelegation.list.invalidate(),
|
||||
const createMutation = trpc.viewer.delegationCredential.add.useMutation({
|
||||
onSuccess: () => utils.viewer.delegationCredential.list.invalidate(),
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const deleteMutation = trpc.viewer.domainWideDelegation.delete.useMutation({
|
||||
onSuccess: () => utils.viewer.domainWideDelegation.list.invalidate(),
|
||||
const deleteMutation = trpc.viewer.delegationCredential.delete.useMutation({
|
||||
onSuccess: () => utils.viewer.delegationCredential.list.invalidate(),
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
@@ -345,7 +345,7 @@ function DomainWideDelegationList() {
|
||||
});
|
||||
|
||||
const { data: workspacePlatforms, isLoading: isLoadingWorkspacePlatforms } =
|
||||
trpc.viewer.domainWideDelegation.listWorkspacePlatforms.useQuery();
|
||||
trpc.viewer.delegationCredential.listWorkspacePlatforms.useQuery();
|
||||
|
||||
const enabledWorkspacePlatforms = workspacePlatforms?.filter((platform) => platform.enabled) || [];
|
||||
|
||||
@@ -379,7 +379,7 @@ function DomainWideDelegationList() {
|
||||
const AddDwDButton = () => {
|
||||
return (
|
||||
<Button type="button" color="secondary" StartIcon="plus" className="mt-6" onClick={onCreateClick}>
|
||||
{t("add_domain_wide_delegation")}
|
||||
{t("add_delegation_credential")}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
@@ -419,8 +419,8 @@ function DomainWideDelegationList() {
|
||||
) : (
|
||||
<EmptyScreen
|
||||
Icon="link"
|
||||
headline={t("add_domain_wide_delegation")}
|
||||
description={t("domain_wide_delegation_description")}
|
||||
headline={t("add_delegation_credential")}
|
||||
description={t("delegation_credential_description")}
|
||||
className="rounded-b-lg rounded-t-none border-t-0"
|
||||
buttonRaw={<AddDwDButton />}
|
||||
/>
|
||||
@@ -446,6 +446,6 @@ function DomainWideDelegationList() {
|
||||
);
|
||||
}
|
||||
|
||||
export default function DomainWideDelegationListPage() {
|
||||
return <DomainWideDelegationList />;
|
||||
export default function DelegationCredentialListPage() {
|
||||
return <DelegationCredentialList />;
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import { scheduleWorkflowReminders } from "@calcom/features/ee/workflows/lib/rem
|
||||
import { isPrismaObjOrUndefined } from "@calcom/lib";
|
||||
import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser";
|
||||
import { SENDER_NAME } from "@calcom/lib/constants";
|
||||
import { enrichUserWithDwdCredentialsWithoutOrgId } from "@calcom/lib/domainWideDelegation/server";
|
||||
import { enrichUserWithDelegationCredentialsWithoutOrgId } from "@calcom/lib/delegationCredential/server";
|
||||
import { getEventName } from "@calcom/lib/event";
|
||||
import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";
|
||||
import logger from "@calcom/lib/logger";
|
||||
@@ -275,7 +275,7 @@ export const roundRobinManualReassignment = async ({
|
||||
include: { user: { select: { email: true } } },
|
||||
});
|
||||
|
||||
const newUserWithCredentials = await enrichUserWithDwdCredentialsWithoutOrgId({
|
||||
const newUserWithCredentials = await enrichUserWithDelegationCredentialsWithoutOrgId({
|
||||
user: { ...newUser, credentials },
|
||||
});
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ import { isPrismaObjOrUndefined } from "@calcom/lib";
|
||||
import { getVideoCallUrlFromCalEvent } from "@calcom/lib/CalEventParser";
|
||||
import { SENDER_NAME } from "@calcom/lib/constants";
|
||||
import {
|
||||
enrichHostsWithDwdCredentials,
|
||||
enrichUserWithDwdCredentialsWithoutOrgId,
|
||||
} from "@calcom/lib/domainWideDelegation/server";
|
||||
enrichHostsWithDelegationCredentials,
|
||||
enrichUserWithDelegationCredentialsWithoutOrgId,
|
||||
} from "@calcom/lib/delegationCredential/server";
|
||||
import { getEventName } from "@calcom/lib/event";
|
||||
import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";
|
||||
import logger from "@calcom/lib/logger";
|
||||
@@ -119,7 +119,7 @@ export const roundRobinReassignment = async ({
|
||||
|
||||
const previousRRHostT = await getTranslation(previousRRHost?.locale || "en", "common");
|
||||
|
||||
const eventTypeHosts = await enrichHostsWithDwdCredentials({
|
||||
const eventTypeHosts = await enrichHostsWithDelegationCredentials({
|
||||
orgId,
|
||||
hosts: eventType.hosts,
|
||||
});
|
||||
@@ -320,7 +320,7 @@ export const roundRobinReassignment = async ({
|
||||
},
|
||||
});
|
||||
|
||||
const organizerWithCredentials = await enrichUserWithDwdCredentialsWithoutOrgId({
|
||||
const organizerWithCredentials = await enrichUserWithDelegationCredentialsWithoutOrgId({
|
||||
user: { ...organizer, credentials },
|
||||
});
|
||||
|
||||
|
||||
@@ -16,6 +16,6 @@ export type AppFlags = {
|
||||
"disable-signup": boolean;
|
||||
attributes: boolean;
|
||||
"organizer-request-email-v2": boolean;
|
||||
"domain-wide-delegation": boolean;
|
||||
"delegation-credential": boolean;
|
||||
"salesforce-crm-tasker": boolean;
|
||||
};
|
||||
@@ -15,7 +15,7 @@ const initialData: AppFlags = {
|
||||
"disable-signup": false,
|
||||
attributes: false,
|
||||
"organizer-request-email-v2": false,
|
||||
"domain-wide-delegation": false,
|
||||
"delegation-credential": false,
|
||||
"salesforce-crm-tasker": false,
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user