fix: removed testing code in sessionjs

This commit is contained in:
Rushil Umaretiya 2023-03-04 21:14:01 -05:00
parent 2476824c33
commit c6219e6e6e

View File

@ -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",
},
],
});
};