fix: fetching event-types of org users apiv2 (#18004)
This commit is contained in:
@@ -7,9 +7,9 @@ import { User } from "@calcom/prisma/client";
|
||||
export class UsersService {
|
||||
constructor(private readonly usersRepository: UsersRepository) {}
|
||||
|
||||
async getByUsernames(usernames: string[]) {
|
||||
async getByUsernames(usernames: string[], orgSlug?: string, orgId?: number) {
|
||||
const users = await Promise.all(
|
||||
usernames.map((username) => this.usersRepository.findByUsername(username))
|
||||
usernames.map((username) => this.usersRepository.findByUsername(username, orgSlug, orgId))
|
||||
);
|
||||
const usersFiltered: User[] = [];
|
||||
|
||||
|
||||
@@ -142,11 +142,21 @@ export class UsersRepository {
|
||||
});
|
||||
}
|
||||
|
||||
async findByUsername(username: string) {
|
||||
async findByUsername(username: string, orgSlug?: string, orgId?: number) {
|
||||
return this.dbRead.prisma.user.findFirst({
|
||||
where: {
|
||||
username,
|
||||
},
|
||||
where:
|
||||
orgId || orgSlug
|
||||
? {
|
||||
profiles: {
|
||||
some: {
|
||||
organization: orgSlug ? { slug: orgSlug } : { id: orgId },
|
||||
username: username,
|
||||
},
|
||||
},
|
||||
}
|
||||
: {
|
||||
username,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user