From be9512580b3e887ea15fa4829ec18f9ed7e438a3 Mon Sep 17 00:00:00 2001 From: Mathieu Valois Date: Mon, 2 Oct 2023 17:33:52 +0200 Subject: [PATCH 1/2] Adds LastActive on /admin/users API route --- src/api/admin.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/admin.rs b/src/api/admin.rs index 9eb965cc86..59beab1e6e 100644 --- a/src/api/admin.rs +++ b/src/api/admin.rs @@ -326,6 +326,10 @@ async fn get_users_json(_token: AdminToken, mut conn: DbConn) -> Json { let mut usr = u.to_json(&mut conn).await; usr["UserEnabled"] = json!(u.enabled); usr["CreatedAt"] = json!(format_naive_datetime_local(&u.created_at, DT_FMT)); + usr["LastActive"] = match u.last_active(&mut conn).await { + Some(dt) => json!(format_naive_datetime_local(&dt, DT_FMT)), + None => json!("Never"), + }; users_json.push(usr); } From 5f69436a697b45e42296dce1dec5a4cac319034c Mon Sep 17 00:00:00 2001 From: Mathieu Valois Date: Tue, 17 Oct 2023 11:18:39 +0200 Subject: [PATCH 2/2] LastActive is null instead of 'Never' when never connected --- src/api/admin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/admin.rs b/src/api/admin.rs index 59beab1e6e..59c770d8e5 100644 --- a/src/api/admin.rs +++ b/src/api/admin.rs @@ -328,7 +328,7 @@ async fn get_users_json(_token: AdminToken, mut conn: DbConn) -> Json { usr["CreatedAt"] = json!(format_naive_datetime_local(&u.created_at, DT_FMT)); usr["LastActive"] = match u.last_active(&mut conn).await { Some(dt) => json!(format_naive_datetime_local(&dt, DT_FMT)), - None => json!("Never"), + None => json!(None::), }; users_json.push(usr); }