From 832c94069c4ef5d7edae0ac18e9d55bcda8ddf9d Mon Sep 17 00:00:00 2001 From: "Philip (a-0)" <@ph:a-0.me> Date: Tue, 30 Aug 2022 10:49:20 +0200 Subject: [PATCH] Added access token and device id persistance. Fixes #3 --- .gitignore | 2 +- src/matrix.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3afb0c8..5c08e5c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /target -config.yaml \ No newline at end of file +config.yaml* \ No newline at end of file diff --git a/src/matrix.rs b/src/matrix.rs index 732d2ab..1c05a96 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -39,6 +39,11 @@ pub async fn get_clients(config: &mut Config) -> Vec { } } } + // If client is logged in, update the config to persist the session + if let Some(session) = client.session().await { + conf.access_token = Some(session.access_token); + conf.device_id = Some(session.device_id.to_string()); + } clients.push(client.clone()); }