(req, res)
| 46 | */ |
| 47 | |
| 48 | const createProgress = async (req, res) => { |
| 49 | if (req.userData.roles?.archived || req.userData.roles?.in_discord !== true) { |
| 50 | return res.boom.forbidden(UNAUTHORIZED_WRITE); |
| 51 | } |
| 52 | |
| 53 | const { |
| 54 | body: { type, completed, planned, blockers, taskId }, |
| 55 | } = req; |
| 56 | try { |
| 57 | const { data, taskTitle } = await progressesModel.createProgressDocument({ ...req.body, userId: req.userData.id }); |
| 58 | await sendTaskUpdate(completed, blockers, planned, req.userData.username, taskId, taskTitle); |
| 59 | return res.status(201).json({ |
| 60 | data, |
| 61 | message: `${type.charAt(0).toUpperCase() + type.slice(1)} ${PROGRESS_DOCUMENT_CREATED_SUCCEEDED}`, |
| 62 | }); |
| 63 | } catch (error) { |
| 64 | if (error instanceof Conflict) { |
| 65 | return res.status(409).json({ |
| 66 | message: error.message, |
| 67 | }); |
| 68 | } else if (error instanceof NotFound) { |
| 69 | return res.status(404).json({ |
| 70 | message: error.message, |
| 71 | }); |
| 72 | } |
| 73 | logger.error(error.message); |
| 74 | return res.status(500).json({ |
| 75 | message: INTERNAL_SERVER_ERROR_MESSAGE, |
| 76 | }); |
| 77 | } |
| 78 | }; |
| 79 | |
| 80 | /** |
| 81 | * @typedef {Object} ProgressQueryParams |
nothing calls this directly
no test coverage detected