Added delete stash icons and dialog.

This commit is contained in:
DebaucheryLibrarian
2021-03-20 23:03:13 +01:00
parent 07643870cd
commit eee47111a6
14 changed files with 204 additions and 33 deletions

View File

@@ -80,6 +80,24 @@ async function updateStash(stashId, newStash, sessionUser) {
return curateStash(stash);
}
async function removeStash(stashId, sessionUser) {
if (!sessionUser) {
throw new HttpError('You are not authenthicated', 401);
}
const removed = await knex('stashes')
.where({
id: stashId,
user_id: sessionUser.id,
deletable: true,
})
.delete();
if (removed === 0) {
throw new HttpError('Unable to remove this stash', 400);
}
}
async function stashActor(actorId, stashId, sessionUser) {
const stash = await fetchStash(stashId, sessionUser);
@@ -149,6 +167,7 @@ async function unstashMovie(movieId, stashId, sessionUser) {
module.exports = {
createStash,
curateStash,
removeStash,
stashActor,
stashScene,
stashMovie,