Multi-environment and multi-user construction

This commit is contained in:
2026-09-15 21:37:58 +03:30
parent e61fad95c6
commit d3f97b9dc4
37 changed files with 1349 additions and 201 deletions
@@ -242,7 +242,11 @@ export class LeadFormsService {
ownerId ??
(
await this.prisma.user.findFirst({
where: { organizationId: form.organizationId, role: 'owner' },
where: {
memberships: {
some: { organizationId: form.organizationId, role: 'owner' },
},
},
select: { id: true },
})
)?.id;
@@ -447,7 +451,10 @@ export class LeadFormsService {
) {
if (!assigneeIds?.length) return;
const count = await this.prisma.user.count({
where: { organizationId, id: { in: assigneeIds } },
where: {
id: { in: assigneeIds },
memberships: { some: { organizationId } },
},
});
if (count !== assigneeIds.length) {
throw new BadRequestException('یکی از مسئولان انتخاب‌شده معتبر نیست');