task agent validation: if agent is not in the crew, replace task agent with null

This commit is contained in:
Eng. Elias
2024-02-29 17:56:42 +04:00
parent fc7d171b8b
commit 3344c01c7b
3 changed files with 23 additions and 9 deletions

View File

@@ -62,9 +62,7 @@ const resolvers = {
for (let task of body.tasks) {
let agent = null;
if (task.agent) {
agent = await prisma.agent.findFirst({
where: { id: task.agent },
});
agent = crew.find((a) => a.id === task.agent) ?? null;
}
tasks.push({
...task,
@@ -97,9 +95,7 @@ const resolvers = {
for (let task of body.tasks) {
let agent = null;
if (task.agent) {
agent = await prisma.agent.findFirst({
where: { id: task.agent },
});
agent = crew.find((a) => a.id === task.agent) ?? null;
}
tasks.push({
...task,