feat: first pass, sharing agents

This commit is contained in:
Danny Avila 2024-09-04 15:29:14 -04:00
parent 0a73caf1d8
commit 1bc0689134
No known key found for this signature in database
GPG key ID: 2DD9CC89B9B50364
8 changed files with 241 additions and 22 deletions

View file

@ -101,10 +101,13 @@ const updateAgentHandler = async (req, res) => {
const id = req.params.id;
const { projectIds, removeProjectIds, ...updateData } = req.body;
const updatedAgent = await updateAgent({ id, author: req.user.id }, updateData);
let updatedAgent;
if (Object.keys(updateData).length > 0) {
updatedAgent = await updateAgent({ id, author: req.user.id }, updateData);
}
if (projectIds || removeProjectIds) {
await updateAgentProjects(id, projectIds, removeProjectIds);
updatedAgent = await updateAgentProjects(id, projectIds, removeProjectIds);
}
return res.json(updatedAgent);