1
1
mirror of https://github.com/ellie/atuin.git synced 2024-07-14 16:20:24 +03:00

feat: allow advertising a fake version to clients (#2228)

* feat: allow advertising a fake version to clients

The server usually runs unstable Atuin, and is well monitored. But let's
not advertised the unstable version to clients, as they will notify
users there is an update available.

* fix test build
This commit is contained in:
Ellie Huxtable 2024-07-02 14:13:45 +01:00 committed by GitHub
parent 884d97d55e
commit 255a7bccb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 1 deletions

View File

@ -19,10 +19,16 @@ pub async fn index<DB: Database>(state: State<AppState<DB>>) -> Json<IndexRespon
// It's super unlikely this will happen
let count = state.database.total_history().await.unwrap_or(-1);
let version = state
.settings
.fake_version
.clone()
.unwrap_or(VERSION.to_string());
Json(IndexResponse {
homage: homage.to_string(),
version: VERSION.to_string(),
total_history: count,
version,
})
}

View File

@ -67,6 +67,13 @@ pub struct Settings<DbSettings> {
pub tls: Tls,
pub mail: Mail,
/// Advertise a version that is not what we are _actually_ running
/// Many clients compare their version with api.atuin.sh, and if they differ, notify the user
/// that an update is available.
/// Now that we take beta releases, we should be able to advertise a different version to avoid
/// notifying users when the server runs something that is not a stable release.
pub fake_version: Option<String>,
#[serde(flatten)]
pub db_settings: DbSettings,
}

View File

@ -39,6 +39,7 @@ pub async fn start_server(path: &str) -> (String, oneshot::Sender<()>, JoinHandl
metrics: atuin_server::settings::Metrics::default(),
tls: atuin_server::settings::Tls::default(),
mail: atuin_server::settings::Mail::default(),
fake_version: None,
};
let (shutdown_tx, shutdown_rx) = tokio::sync::oneshot::channel();