add: stack clones
This commit is contained in:
parent
3a48ef2969
commit
eec81f5718
5 changed files with 55 additions and 0 deletions
|
@ -665,6 +665,7 @@ pub fn routes() -> Router {
|
|||
.route("/stacks", get(stacks::list_request))
|
||||
.route("/stacks", post(stacks::create_request))
|
||||
.route("/stacks/{id}", get(stacks::get_request))
|
||||
.route("/stacks/{id}/clone", post(stacks::clone_request))
|
||||
.route("/stacks/{id}/name", post(stacks::update_name_request))
|
||||
.route("/stacks/{id}/privacy", post(stacks::update_privacy_request))
|
||||
.route("/stacks/{id}/mode", post(stacks::update_mode_request))
|
||||
|
|
|
@ -91,6 +91,27 @@ pub async fn create_request(
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn clone_request(
|
||||
jar: CookieJar,
|
||||
Extension(data): Extension<State>,
|
||||
Path(id): Path<usize>,
|
||||
) -> impl IntoResponse {
|
||||
let data = &(data.read().await).0;
|
||||
let user = match get_user_from_token!(jar, data, oauth::AppScope::UserCreateStacks) {
|
||||
Some(ua) => ua,
|
||||
None => return Json(Error::NotAllowed.into()),
|
||||
};
|
||||
|
||||
match data.clone_stack(user.id, id).await {
|
||||
Ok(s) => Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Stack created".to_string(),
|
||||
payload: s.id.to_string(),
|
||||
}),
|
||||
Err(e) => Json(e.into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn update_name_request(
|
||||
jar: CookieJar,
|
||||
Extension(data): Extension<State>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue