Skip to content

Commit 4b97842

Browse files
committed
fix/assignee-bug
1 parent f934b6f commit 4b97842

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

controllers/tasks.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const { OLD_ACTIVE, OLD_BLOCKED, OLD_PENDING } = TASK_STATUS_OLD;
77
const { IN_PROGRESS, BLOCKED, SMOKE_TESTING, ASSIGNED } = TASK_STATUS;
88
const { INTERNAL_SERVER_ERROR, SOMETHING_WENT_WRONG } = require("../constants/errorMessages");
99
const dependencyModel = require("../models/tasks");
10+
const userQuery = require("../models/users");
1011
/**
1112
* Creates new task
1213
*
@@ -177,7 +178,12 @@ const updateTask = async (req, res) => {
177178
if (!task.taskData) {
178179
return res.boom.notFound("Task not found");
179180
}
180-
181+
if (req.body.assignee) {
182+
const user = await userQuery.fetchUser({ username: req.body.assignee });
183+
if (!user.userExists) {
184+
return res.boom.notFound("User doesn't exist");
185+
}
186+
}
181187
await tasks.updateTask(req.body, req.params.id);
182188
return res.status(204).send();
183189
} catch (err) {

0 commit comments

Comments
 (0)