mirror of
https://github.com/vitalityAI/therapist.git
synced 2025-04-11 07:10:16 -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({
|
||||
data: {
|
||||
callId: callId,
|
||||
callerPhone: callerPhone
|
||||
}
|
||||
})
|
||||
}
|
||||
callerPhone: callerPhone,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const findSessionByCallId = async (callId) => {
|
||||
return await db.session.findUnique({
|
||||
where: {
|
||||
callId: callId
|
||||
}
|
||||
})
|
||||
}
|
||||
callId: callId,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const transferSession = async (callId, operatorPhone) => {
|
||||
return await db.session.update({
|
||||
where: {
|
||||
callId: callId
|
||||
callId: callId,
|
||||
},
|
||||
data: {
|
||||
transferedAt: new Date(),
|
||||
operatorPhone: operatorPhone
|
||||
}
|
||||
})
|
||||
}
|
||||
operatorPhone: operatorPhone,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const endSession = async (callId) => {
|
||||
return await db.session.update({
|
||||
where: {
|
||||
callId: callId
|
||||
callId: callId,
|
||||
},
|
||||
data: {
|
||||
endedAt: new Date()
|
||||
}
|
||||
})
|
||||
}
|
||||
endedAt: new Date(),
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const addMessage = async (callId, role, content) => {
|
||||
const session = await findSessionByCallId(callId)
|
||||
const session = await findSessionByCallId(callId);
|
||||
return await db.message.create({
|
||||
data: {
|
||||
sessionId: session.id,
|
||||
role: role,
|
||||
content: content
|
||||
}
|
||||
})
|
||||
}
|
||||
content: content,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const getMessages = async (callId) => {
|
||||
return await db.message.findMany({
|
||||
where: {
|
||||
session: {
|
||||
callId: callId
|
||||
}
|
||||
callId: callId,
|
||||
},
|
||||
},
|
||||
orderBy: [
|
||||
{
|
||||
createdAt: 'asc'
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
// const main = async () => {
|
||||
// // await addMessage("ofijse", Role.USER, "wefoij")
|
||||
// console.log(await getMessages("ofijse"))
|
||||
// }
|
||||
|
||||
// main()
|
||||
createdAt: "asc",
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user