mirror of
https://github.com/vitalityAI/therapist.git
synced 2025-04-18 10:30:17 -04:00
fix: removed testing code in sessionjs
This commit is contained in:
parent
2476824c33
commit
c6219e6e6e
|
@ -5,71 +5,64 @@ export const createSession = async (callId, callerPhone) => {
|
||||||
return await db.session.create({
|
return await db.session.create({
|
||||||
data: {
|
data: {
|
||||||
callId: callId,
|
callId: callId,
|
||||||
callerPhone: callerPhone
|
callerPhone: callerPhone,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
export const findSessionByCallId = async (callId) => {
|
export const findSessionByCallId = async (callId) => {
|
||||||
return await db.session.findUnique({
|
return await db.session.findUnique({
|
||||||
where: {
|
where: {
|
||||||
callId: callId
|
callId: callId,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
export const transferSession = async (callId, operatorPhone) => {
|
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(),
|
||||||
operatorPhone: operatorPhone
|
operatorPhone: operatorPhone,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
export const endSession = async (callId) => {
|
export const endSession = async (callId) => {
|
||||||
return await db.session.update({
|
return await db.session.update({
|
||||||
where: {
|
where: {
|
||||||
callId: callId
|
callId: callId,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
endedAt: new Date()
|
endedAt: new Date(),
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
export const addMessage = async (callId, role, content) => {
|
export const addMessage = async (callId, role, content) => {
|
||||||
const session = await findSessionByCallId(callId)
|
const session = await findSessionByCallId(callId);
|
||||||
return await db.message.create({
|
return await db.message.create({
|
||||||
data: {
|
data: {
|
||||||
sessionId: session.id,
|
sessionId: session.id,
|
||||||
role: role,
|
role: role,
|
||||||
content: content
|
content: content,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
export const getMessages = async (callId) => {
|
export const getMessages = async (callId) => {
|
||||||
return await db.message.findMany({
|
return await db.message.findMany({
|
||||||
where: {
|
where: {
|
||||||
session: {
|
session: {
|
||||||
callId: callId
|
callId: callId,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
orderBy: [
|
orderBy: [
|
||||||
{
|
{
|
||||||
createdAt: 'asc'
|
createdAt: "asc",
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
// const main = async () => {
|
|
||||||
// // await addMessage("ofijse", Role.USER, "wefoij")
|
|
||||||
// console.log(await getMessages("ofijse"))
|
|
||||||
// }
|
|
||||||
|
|
||||||
// main()
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user