Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions backend/src/api/public/v1/organizations/createOrganization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@ const bodySchema = z.object({
name: z.string().trim().min(1),
domain: z.string().trim().min(1),
source: z.string().trim().min(1),
logo: z.string().trim().min(1).optional(),
})

export async function createOrganization(req: Request, res: Response): Promise<void> {
const { name, domain, source } = validateOrThrow(bodySchema, req.body)
const { name, domain, source, logo } = validateOrThrow(bodySchema, req.body)

const qx = optionsQx(req)

let organizationId: string | undefined

await qx.tx(async (tx) => {
const orgSource = OrganizationAttributeSource.CUSTOM
const orgSource = OrganizationAttributeSource.LFX_SERVE

organizationId = await findOrCreateOrganization(tx, orgSource, {
displayName: name,
logo,
identities: [
Comment thread
joanagmaia marked this conversation as resolved.
{
value: domain,
Expand Down Expand Up @@ -59,5 +61,5 @@ export async function createOrganization(req: Request, res: Response): Promise<v
)
})

created(res, { id: organizationId, name })
created(res, { id: organizationId, name, logo })
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export function findAttribute(name: string): OrgAttributeDef {

export const ORG_DB_ATTRIBUTE_SOURCE_PRIORITY = [
OrganizationAttributeSource.CUSTOM,
OrganizationAttributeSource.LFX_SERVE,
OrganizationAttributeSource.ENRICHMENT_LFX_INTERNAL_API,
OrganizationAttributeSource.ENRICHMENT_PEOPLEDATALABS,
OrganizationAttributeSource.CVENT,
Expand Down
1 change: 1 addition & 0 deletions services/libs/types/src/enums/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export enum OrganizationIdentityType {

export enum OrganizationAttributeSource {
CUSTOM = 'custom',
LFX_SERVE = 'lfx-serve',
ENRICHMENT_LFX_INTERNAL_API = 'enrichment-lfx-internal-api',
ENRICHMENT_PEOPLEDATALABS = 'enrichment-peopledatalabs',
CVENT = 'cvent',
Expand Down
Loading