feat: Add booking and user creation source (#18768)
* migration and init to accept creationSource for new bookings * V1 create booking * V1 user creation * webapp booking + V1 user * user creation in V1, V2 and webapp * booking source V2 and fix for v1 user * fit type * --fix type * add test -- WIP * fix type * fix type * ^ * Need more sleep zzz * -_- * bump libraries platform * adds for v2 recurring booking * fix lint * instant meetings * fix: api v2 creation source * fixup! fix: api v2 creation source * bump libraries * add user * fix test * fixup! fix test * add more source * more source... * fix type & test --1 * fix type & test --2 * typefix * fixup test --------- Co-authored-by: Morgan Vernay <[email protected]>
This commit is contained in:
1 parent
3f622fe277
commit
41f63582b2
46 files changed
+261
-18
No files matched your search
@@ -9,6 +9,7 @@ import { defaultHandler, defaultResponder } from "@calcom/lib/server";
|
||||
import slugify from "@calcom/lib/slugify";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { IdentityProvider } from "@calcom/prisma/enums";
|
||||
import { CreationSource } from "@calcom/prisma/enums";
|
||||
|
||||
const querySchema = z.object({
|
||||
username: z
|
||||
@@ -48,6 +49,7 @@ async function handler(req: NextApiRequest) {
|
||||
emailVerified: new Date(),
|
||||
locale: "en", // TODO: We should revisit this
|
||||
identityProvider: IdentityProvider.CAL,
|
||||
creationSource: CreationSource.WEBAPP,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { organizationScenarios } from "@calcom/lib/server/repository/__mocks__/o
|
||||
import { describe, it, expect, beforeEach, vi } from "vitest";
|
||||
|
||||
import { MembershipRole } from "@calcom/prisma/client";
|
||||
import { CreationSource } from "@calcom/prisma/enums";
|
||||
import { inviteMembersWithNoInviterPermissionCheck } from "@calcom/trpc/server/routers/viewer/teams/inviteMember/inviteMember.handler";
|
||||
|
||||
import { moveUserToMatchingOrg } from "./verify-email";
|
||||
@@ -29,6 +30,7 @@ describe("moveUserToMatchingOrg", () => {
|
||||
const argToInviteMembersWithNoInviterPermissionCheck = {
|
||||
inviterName: null,
|
||||
language: "en",
|
||||
creationSource: CreationSource.WEBAPP,
|
||||
invitations: [
|
||||
{
|
||||
usernameOrEmail: email,
|
||||
|
||||
@@ -8,6 +8,7 @@ import { IS_STRIPE_ENABLED } from "@calcom/lib/constants";
|
||||
import { OrganizationRepository } from "@calcom/lib/server/repository/organization";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import { MembershipRole } from "@calcom/prisma/client";
|
||||
import { CreationSource } from "@calcom/prisma/enums";
|
||||
import { userMetadata } from "@calcom/prisma/zod-utils";
|
||||
import { inviteMembersWithNoInviterPermissionCheck } from "@calcom/trpc/server/routers/viewer/teams/inviteMember/inviteMember.handler";
|
||||
|
||||
@@ -29,6 +30,7 @@ export async function moveUserToMatchingOrg({ email }: { email: string }) {
|
||||
inviterName: null,
|
||||
teamId: org.id,
|
||||
language: "en",
|
||||
creationSource: CreationSource.WEBAPP,
|
||||
invitations: [
|
||||
{
|
||||
usernameOrEmail: email,
|
||||
|
||||
@@ -6,6 +6,7 @@ import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowE
|
||||
import getIP from "@calcom/lib/getIP";
|
||||
import { defaultResponder } from "@calcom/lib/server";
|
||||
import { checkCfTurnstileToken } from "@calcom/lib/server/checkCfTurnstileToken";
|
||||
import { CreationSource } from "@calcom/prisma/enums";
|
||||
|
||||
async function handler(req: NextApiRequest & { userId?: number }, res: NextApiResponse) {
|
||||
const userIp = getIP(req);
|
||||
@@ -25,6 +26,10 @@ async function handler(req: NextApiRequest & { userId?: number }, res: NextApiRe
|
||||
const session = await getServerSession({ req, res });
|
||||
/* To mimic API behavior and comply with types */
|
||||
req.userId = session?.user?.id || -1;
|
||||
req.body = {
|
||||
...req.body,
|
||||
creationSource: CreationSource.WEBAPP,
|
||||
};
|
||||
const booking = await handleNewBooking(req);
|
||||
return booking;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import handleInstantMeeting from "@calcom/features/instant-meeting/handleInstant
|
||||
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
|
||||
import getIP from "@calcom/lib/getIP";
|
||||
import { defaultResponder } from "@calcom/lib/server";
|
||||
import { CreationSource } from "@calcom/prisma/enums";
|
||||
|
||||
async function handler(req: NextApiRequest & { userId?: number }, res: NextApiResponse) {
|
||||
const userIp = getIP(req);
|
||||
@@ -16,6 +17,7 @@ async function handler(req: NextApiRequest & { userId?: number }, res: NextApiRe
|
||||
|
||||
const session = await getServerSession({ req, res });
|
||||
req.userId = session?.user?.id || -1;
|
||||
req.body.creationSource = CreationSource.WEBAPP;
|
||||
const booking = await handleInstantMeeting(req);
|
||||
return booking;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { getDate } from "@calcom/web/test/utils/bookingScenario/bookingScenario";
|
||||
|
||||
import type { SchedulingType } from "@calcom/prisma/client";
|
||||
import type { CreationSource } from "@calcom/prisma/enums";
|
||||
|
||||
export const DEFAULT_TIMEZONE_BOOKER = "Asia/Kolkata";
|
||||
export function getBasicMockRequestDataForBooking() {
|
||||
@@ -40,6 +41,7 @@ export function getMockRequestDataForBooking({
|
||||
data: Partial<ReturnType<typeof getBasicMockRequestDataForBooking>> & {
|
||||
eventTypeId: number;
|
||||
user?: string;
|
||||
creationSource?: CreationSource;
|
||||
} & CommonPropsMockRequestData;
|
||||
}) {
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user