diff --git a/atuin-common/src/api.rs b/atuin-common/src/api.rs index d9334ffc..99b57cec 100644 --- a/atuin-common/src/api.rs +++ b/atuin-common/src/api.rs @@ -115,3 +115,8 @@ pub struct DeleteHistoryRequest { pub struct MessageResponse { pub message: String, } + +#[derive(Debug, Serialize, Deserialize)] +pub struct MeResponse { + pub username: String, +} diff --git a/atuin-server/src/handlers/v0/me.rs b/atuin-server/src/handlers/v0/me.rs new file mode 100644 index 00000000..7960b479 --- /dev/null +++ b/atuin-server/src/handlers/v0/me.rs @@ -0,0 +1,16 @@ +use axum::Json; +use tracing::instrument; + +use crate::handlers::ErrorResponseStatus; +use crate::router::UserAuth; + +use atuin_common::api::*; + +#[instrument(skip_all, fields(user.id = user.id))] +pub async fn get( + UserAuth(user): UserAuth, +) -> Result, ErrorResponseStatus<'static>> { + Ok(Json(MeResponse { + username: user.username, + })) +} diff --git a/atuin-server/src/handlers/v0/mod.rs b/atuin-server/src/handlers/v0/mod.rs index 2d6745cf..d6f880f2 100644 --- a/atuin-server/src/handlers/v0/mod.rs +++ b/atuin-server/src/handlers/v0/mod.rs @@ -1,2 +1,3 @@ +pub(crate) mod me; pub(crate) mod record; pub(crate) mod store; diff --git a/atuin-server/src/router.rs b/atuin-server/src/router.rs index 52fc1484..96dff2bd 100644 --- a/atuin-server/src/router.rs +++ b/atuin-server/src/router.rs @@ -125,6 +125,7 @@ pub fn router(database: DB, settings: Settings) -> R .route("/record", post(handlers::record::post::)) .route("/record", get(handlers::record::index::)) .route("/record/next", get(handlers::record::next)) + .route("/api/v0/me", get(handlers::v0::me::get)) .route("/api/v0/record", post(handlers::v0::record::post)) .route("/api/v0/record", get(handlers::v0::record::index)) .route("/api/v0/record/next", get(handlers::v0::record::next)) diff --git a/atuin/src/command/client/sync/status.rs b/atuin/src/command/client/sync/status.rs index 333a0fad..29a1e113 100644 --- a/atuin/src/command/client/sync/status.rs +++ b/atuin/src/command/client/sync/status.rs @@ -23,8 +23,6 @@ pub async fn run(settings: &Settings, db: &impl Database) -> Result<()> { let status = client.status().await?; let last_sync = Settings::last_sync()?; - let local_count = db.history_count(false).await?; - let deleted_count = db.history_count(true).await? - local_count; println!("Atuin v{VERSION} - Build rev {SHA}\n"); @@ -36,6 +34,9 @@ pub async fn run(settings: &Settings, db: &impl Database) -> Result<()> { } if !settings.sync.records { + let local_count = db.history_count(false).await?; + let deleted_count = db.history_count(true).await? - local_count; + println!("History count: {local_count}"); println!("Deleted history count: {deleted_count}\n"); }