This commit is contained in:
Claeb101 2023-03-04 21:11:24 -05:00
parent fbfc0d014c
commit 87814fc962
2 changed files with 16 additions and 4 deletions

View File

@ -19,14 +19,17 @@ model Session {
callId String @unique callId String @unique
callerPhone String @unique callerPhone String @unique
receiverPhone String? @unique
operatorPhone String? @unique
operator Operator? @relation(fields: [operatorPhone], references: [phoneNumber])
messages Message[] messages Message[]
} }
enum Role { enum Role {
USER USER
BOT BOT
REP OPERATOR
} }
model Message { model Message {
@ -39,3 +42,12 @@ model Message {
session Session @relation(fields: [sessionId], references: [id]) session Session @relation(fields: [sessionId], references: [id])
sessionId String @db.ObjectId sessionId String @db.ObjectId
} }
model Operator {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String
phoneNumber String @unique
email String @unique
sessions Session[]
}

View File

@ -18,14 +18,14 @@ export const findSessionByCallId = async (callId) => {
}) })
} }
export const transferSession = async (callId, receiverPhone) => { export const transferSession = async (callId, operatorPhone) => {
return await db.session.update({ return await db.session.update({
where: { where: {
callId: callId callId: callId
}, },
data: { data: {
transferedAt: new Date(), transferedAt: new Date(),
receiverPhone: receiverPhone operatorPhone: operatorPhone
} }
}) })
} }