fix: api v2 get event-types non org users (#26896)
* fix: get event-types non org users * fix: add excludeOrgUsers parameter to findByUsername for targeted filtering Co-Authored-By: morgan@cal.com <morgan@cal.com> * fix: create dedicated findByUsernameExcludingOrgUsers function Co-Authored-By: morgan@cal.com <morgan@cal.com> * test: add e2e test for same username org vs non-org user event types Co-Authored-By: morgan@cal.com <morgan@cal.com> * test: move e2e test for same username org vs non-org to 2024_06_14 Co-Authored-By: morgan@cal.com <morgan@cal.com> * fix: add organizationId to orgUser in e2e test Co-Authored-By: morgan@cal.com <morgan@cal.com> * fix: reorder afterAll cleanup to delete users before team Co-Authored-By: morgan@cal.com <morgan@cal.com> * fix: add organizationId null check to findByUsernameExcludingOrgUsers Co-Authored-By: morgan@cal.com <morgan@cal.com> * Revert "fix: add organizationId null check to findByUsernameExcludingOrgUsers" This reverts commit 0d31e3d5d7c0eaa408939d697ea790521e520a3c. * fixup! fix: add organizationId null check to findByUsernameExcludingOrgUsers * fix: restore /public suffix in e2e test URL Co-Authored-By: morgan@cal.com <morgan@cal.com> * fix: use findByUsernameExcludingOrgUsers in getEventTypeByUsernameAndSlug when no org context Co-Authored-By: morgan@cal.com <morgan@cal.com> * fixup! fix: use findByUsernameExcludingOrgUsers in getEventTypeByUsernameAndSlug when no org context * refactor: remove unused getEventTypesPublicByUsername from 2024_06_14 service Co-Authored-By: morgan@cal.com <morgan@cal.com> * fix: test user creation * chore: add test for org event-types --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
morgan@cal.com <morgan@cal.com>
morgan@cal.com <morgan@cal.com>
morgan@cal.com <morgan@cal.com>
morgan@cal.com <morgan@cal.com>
morgan@cal.com <morgan@cal.com>
morgan@cal.com <morgan@cal.com>
morgan@cal.com <morgan@cal.com>
morgan@cal.com <morgan@cal.com>
morgan@cal.com <morgan@cal.com>
morgan@cal.com <morgan@cal.com>
Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
f5085af396
commit
77c8e34073
@@ -1,11 +1,10 @@
|
||||
import { CreationSource } from "@calcom/platform-libraries";
|
||||
import type { Prisma, Profile, Team, User } from "@calcom/prisma/client";
|
||||
import { Injectable, NotFoundException } from "@nestjs/common";
|
||||
import { PrismaReadService } from "@/modules/prisma/prisma-read.service";
|
||||
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
||||
import { CreateManagedUserInput } from "@/modules/users/inputs/create-managed-user.input";
|
||||
import { UpdateManagedUserInput } from "@/modules/users/inputs/update-managed-user.input";
|
||||
import { Injectable, NotFoundException } from "@nestjs/common";
|
||||
|
||||
import { CreationSource } from "@calcom/platform-libraries";
|
||||
import type { Profile, User, Team, Prisma } from "@calcom/prisma/client";
|
||||
|
||||
export type UserWithProfile = User & {
|
||||
movedToProfile?: (Profile & { organization: Pick<Team, "isPlatform" | "id" | "slug" | "name"> }) | null;
|
||||
@@ -14,7 +13,10 @@ export type UserWithProfile = User & {
|
||||
|
||||
@Injectable()
|
||||
export class UsersRepository {
|
||||
constructor(private readonly dbRead: PrismaReadService, private readonly dbWrite: PrismaWriteService) {}
|
||||
constructor(
|
||||
private readonly dbRead: PrismaReadService,
|
||||
private readonly dbWrite: PrismaWriteService
|
||||
) {}
|
||||
|
||||
async create(
|
||||
user: CreateManagedUserInput,
|
||||
@@ -182,6 +184,15 @@ export class UsersRepository {
|
||||
});
|
||||
}
|
||||
|
||||
async findByUsernameExcludingOrgUsers(username: string) {
|
||||
return this.dbRead.prisma.user.findFirst({
|
||||
where: {
|
||||
username,
|
||||
profiles: { none: {} },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async findManagedUsersByOAuthClientId(oauthClientId: string, cursor: number, limit: number) {
|
||||
return this.dbRead.prisma.user.findMany({
|
||||
where: {
|
||||
|
||||
Reference in New Issue
Block a user