fix: add cipher details to attachment delete response
This commit is contained in:
parent
2591e2e46f
commit
d6ef6113fd
2 changed files with 26 additions and 5 deletions
|
|
@ -54,6 +54,12 @@ pub struct AttachmentUploadResponse {
|
||||||
pub cipher_response: Cipher,
|
pub cipher_response: Cipher,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct AttachmentDeleteResponse {
|
||||||
|
pub cipher: Cipher,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum NumberOrString {
|
pub enum NumberOrString {
|
||||||
|
|
@ -346,8 +352,9 @@ pub async fn get_attachment(
|
||||||
pub async fn delete_attachment(
|
pub async fn delete_attachment(
|
||||||
claims: Claims,
|
claims: Claims,
|
||||||
State(env): State<Arc<Env>>,
|
State(env): State<Arc<Env>>,
|
||||||
|
Extension(BaseUrl(base_url)): Extension<BaseUrl>,
|
||||||
Path((cipher_id, attachment_id)): Path<(String, String)>,
|
Path((cipher_id, attachment_id)): Path<(String, String)>,
|
||||||
) -> Result<Json<()>, AppError> {
|
) -> Result<Json<AttachmentDeleteResponse>, AppError> {
|
||||||
let bucket = require_bucket(&env)?;
|
let bucket = require_bucket(&env)?;
|
||||||
let db = db::get_db(&env)?;
|
let db = db::get_db(&env)?;
|
||||||
|
|
||||||
|
|
@ -376,7 +383,14 @@ pub async fn delete_attachment(
|
||||||
touch_cipher_updated_at(&db, &cipher_id).await?;
|
touch_cipher_updated_at(&db, &cipher_id).await?;
|
||||||
db::touch_user_updated_at(&db, &claims.sub).await?;
|
db::touch_user_updated_at(&db, &claims.sub).await?;
|
||||||
|
|
||||||
Ok(Json(()))
|
// Reload cipher to return fresh updated_at and attachments state
|
||||||
|
let mut cipher_response: Cipher =
|
||||||
|
ensure_cipher_for_user(&db, &cipher_id, &claims.sub).await?.into();
|
||||||
|
hydrate_cipher_attachments(&db, &env, &base_url, &mut cipher_response, &claims.sub).await?;
|
||||||
|
|
||||||
|
Ok(Json(AttachmentDeleteResponse {
|
||||||
|
cipher: cipher_response,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// POST /api/ciphers/{cipher_id}/attachment/{attachment_id}/delete
|
/// POST /api/ciphers/{cipher_id}/attachment/{attachment_id}/delete
|
||||||
|
|
@ -385,9 +399,16 @@ pub async fn delete_attachment(
|
||||||
pub async fn delete_attachment_post(
|
pub async fn delete_attachment_post(
|
||||||
claims: Claims,
|
claims: Claims,
|
||||||
State(env): State<Arc<Env>>,
|
State(env): State<Arc<Env>>,
|
||||||
|
Extension(BaseUrl(base_url)): Extension<BaseUrl>,
|
||||||
Path((cipher_id, attachment_id)): Path<(String, String)>,
|
Path((cipher_id, attachment_id)): Path<(String, String)>,
|
||||||
) -> Result<Json<()>, AppError> {
|
) -> Result<Json<AttachmentDeleteResponse>, AppError> {
|
||||||
delete_attachment(claims, State(env), Path((cipher_id, attachment_id))).await
|
delete_attachment(
|
||||||
|
claims,
|
||||||
|
State(env),
|
||||||
|
Extension(BaseUrl(base_url)),
|
||||||
|
Path((cipher_id, attachment_id)),
|
||||||
|
)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GET /api/ciphers/{cipher_id}/attachment/{attachment_id}/download
|
/// GET /api/ciphers/{cipher_id}/attachment/{attachment_id}/download
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ impl Into<Cipher> for CipherDBModel {
|
||||||
deleted_at: self.deleted_at,
|
deleted_at: self.deleted_at,
|
||||||
created_at: self.created_at,
|
created_at: self.created_at,
|
||||||
updated_at: self.updated_at,
|
updated_at: self.updated_at,
|
||||||
object: "cipherDetails".to_string(),
|
object: default_object(),
|
||||||
organization_use_totp: false,
|
organization_use_totp: false,
|
||||||
edit: true,
|
edit: true,
|
||||||
view_password: true,
|
view_password: true,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue