add: stack clones

This commit is contained in:
trisua 2025-08-15 19:09:37 -04:00
parent 3a48ef2969
commit eec81f5718
5 changed files with 55 additions and 0 deletions

View file

@ -247,6 +247,13 @@ impl DataManager {
Ok(())
}
/// Clone the given stack.
pub async fn clone_stack(&self, owner: usize, stack: usize) -> Result<UserStack> {
let stack = self.get_stack_by_id(stack).await?;
self.create_stack(UserStack::new(stack.name, owner, stack.users))
.await
}
auto_method!(update_stack_name(&str)@get_stack_by_id:FinePermission::MANAGE_STACKS; -> "UPDATE stacks SET name = $1 WHERE id = $2" --cache-key-tmpl="atto.stack:{}");
auto_method!(update_stack_users(Vec<usize>)@get_stack_by_id:FinePermission::MANAGE_STACKS; -> "UPDATE stacks SET users = $1 WHERE id = $2" --serde --cache-key-tmpl="atto.stack:{}");