prepare multiple phone numbers in one account
This commit is contained in:
parent
cea47251dd
commit
5f6100b0bb
@ -10,11 +10,7 @@ export const authenticateUser = async (rawEmail: string, rawPassword: string) =>
|
|||||||
where: { email },
|
where: { email },
|
||||||
include: {
|
include: {
|
||||||
memberships: {
|
memberships: {
|
||||||
include: {
|
include: { organization: true },
|
||||||
organization: {
|
|
||||||
include: { phoneNumbers: true },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -32,7 +32,7 @@ export default resolver.pipe(resolver.zod(Body), resolver.authorize(), async ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const phoneNumber = organization.phoneNumbers[0];
|
const phoneNumber = organization.phoneNumbers[0]; // TODO: use the active number, not the first one
|
||||||
if (!phoneNumber) {
|
if (!phoneNumber) {
|
||||||
throw new NotFoundError();
|
throw new NotFoundError();
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ export default resolver.pipe(
|
|||||||
throw new NotFoundError();
|
throw new NotFoundError();
|
||||||
}
|
}
|
||||||
|
|
||||||
const phoneNumberId = organization.phoneNumbers[0].id;
|
const phoneNumberId = organization.phoneNumbers[0].id; // TODO: use the active number, not the first one
|
||||||
const processingState = await db.processingPhoneNumber.findFirst({ where: { organizationId, phoneNumberId } });
|
const processingState = await db.processingPhoneNumber.findFirst({ where: { organizationId, phoneNumberId } });
|
||||||
if (processingState && !processingState.hasFetchedMessages) {
|
if (processingState && !processingState.hasFetchedMessages) {
|
||||||
return;
|
return;
|
||||||
|
@ -30,6 +30,7 @@ export default async function incomingCallHandler(req: BlitzApiRequest, res: Bli
|
|||||||
const recipient = req.body.To;
|
const recipient = req.body.To;
|
||||||
const organizationId = req.body.From.slice("client:".length).split("__")[0];
|
const organizationId = req.body.From.slice("client:".length).split("__")[0];
|
||||||
const phoneNumber = await db.phoneNumber.findFirst({
|
const phoneNumber = await db.phoneNumber.findFirst({
|
||||||
|
// TODO: use the active number, not the first one
|
||||||
where: { organizationId },
|
where: { organizationId },
|
||||||
include: {
|
include: {
|
||||||
organization: {
|
organization: {
|
||||||
|
@ -11,6 +11,7 @@ export default resolver.pipe(
|
|||||||
enforceSuperAdminIfNotCurrentOrganization,
|
enforceSuperAdminIfNotCurrentOrganization,
|
||||||
async ({ organizationId }) => {
|
async ({ organizationId }) => {
|
||||||
return db.phoneNumber.findFirst({
|
return db.phoneNumber.findFirst({
|
||||||
|
// TODO: use the active number, not the first one
|
||||||
where: { organizationId },
|
where: { organizationId },
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user