1 parent
5b22add1f3
commit
2c98b8f925
38 files changed
+915
-87
No files matched your search
@@ -0,0 +1,27 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use axum::{Extension, Json};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::auth::session::SessionState;
|
||||
use crate::config::AppConfig;
|
||||
use crate::db;
|
||||
use crate::error::AppError;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct ResetSettingsResponse {
|
||||
ok: bool,
|
||||
}
|
||||
|
||||
pub async fn reset_all_settings(
|
||||
Extension(session): Extension<SessionState>,
|
||||
Extension(config): Extension<Arc<AppConfig>>,
|
||||
) -> Result<Response, AppError> {
|
||||
let mut conn = db::pool::open_user_db(&config.data_dir, &session.user_hash)
|
||||
.map_err(|error| AppError::InternalError(format!("Database error: {error}")))?;
|
||||
|
||||
db::settings::reset_all(&mut conn).map_err(AppError::InternalError)?;
|
||||
|
||||
Ok(Json(ResetSettingsResponse { ok: true }).into_response())
|
||||
}
|
||||
Reference in new issue
Block a user