Skip to content

Commit

Permalink
Adding hasBackups property to /backup/deviceAsFolder endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisAlejandro committed Mar 22, 2024
1 parent c70ae9c commit 16ac5a5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/app/services/backups.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ module.exports = (Model, App) => {
const folder = await Model.folder.findOne({ where: { id, user_id: userData.id } });
if (!folder) throw createHttpError(404, 'Folder does not exist');

return folder;
const device = await Model.device.findOne({
where: { name: folder.name, userId: userData.id },
include: [{ model: Model.backup }],
});
if (!device) throw createHttpError(404, 'Device does not exist');

return { ...folder, hasBackups: !device.backups || !!device.backups.length };
};

const renameDeviceAsFolder = async (userData, id, deviceName) => {
Expand Down

0 comments on commit 16ac5a5

Please sign in to comment.