Added public visibility toggle to user page stashes.

This commit is contained in:
DebaucheryLibrarian
2021-03-20 02:03:30 +01:00
parent 011f10fba8
commit 4bc6ff846d
11 changed files with 240 additions and 24 deletions

View File

@@ -29,11 +29,31 @@ async function fetchStash(stashId, sessionUser) {
})
.first();
if (!stash) {
throw new HttpError('You are not authorized to access this stash', 403);
}
return curateStash(stash);
}
async function updateStash(stashId, newStash, sessionUser) {
if (!sessionUser) {
throw new HttpError('You are not authenthicated', 401);
}
const stash = await knex('stashes')
.where({
id: stashId,
user_id: sessionUser.id,
})
.update(newStash)
.returning('*');
if (!stash) {
throw new HttpError('You are not authorized to modify this stash', 403);
}
return stash;
return curateStash(stash);
}
async function stashActor(actorId, stashId, sessionUser) {
@@ -110,4 +130,5 @@ module.exports = {
unstashScene,
unstashActor,
unstashMovie,
updateStash,
};