* Revert "Revert "chore: Chore team metadata table + isOrganization migration from metadata (#12828)""
This reverts commit 2408338ed4.
* Remove constraint slug,isOrganization and reset migration
* fix: conflicts
* change schema to bust cache
* Fix issues reported by TS
* change schema to bust cache
* Review fixes
* Colaesce for orgAutoAcceptEmail as well
* Fix missing negation
---------
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
44 lines
948 B
TypeScript
44 lines
948 B
TypeScript
import { prisma } from "@calcom/prisma";
|
|
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
|
|
|
|
import type { TrpcSessionUser } from "../../../trpc";
|
|
|
|
type AdminGetAllOptions = {
|
|
ctx: {
|
|
user: NonNullable<TrpcSessionUser>;
|
|
};
|
|
};
|
|
|
|
export const adminGetUnverifiedHandler = async ({}: AdminGetAllOptions) => {
|
|
const allOrgs = await prisma.team.findMany({
|
|
where: {
|
|
isOrganization: true,
|
|
},
|
|
select: {
|
|
id: true,
|
|
name: true,
|
|
slug: true,
|
|
metadata: true,
|
|
organizationSettings: true,
|
|
members: {
|
|
where: {
|
|
role: "OWNER",
|
|
},
|
|
select: {
|
|
user: {
|
|
select: {
|
|
id: true,
|
|
name: true,
|
|
email: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
return allOrgs.map((org) => ({ ...org, metadata: teamMetadataSchema.parse(org.metadata) }));
|
|
};
|
|
|
|
export default adminGetUnverifiedHandler;
|