From 6af5c860811f8d51fc1cc579e9a01ff55924b537 Mon Sep 17 00:00:00 2001 From: BlackDex Date: Sun, 6 Nov 2022 18:07:09 +0100 Subject: [PATCH] Add `/devices/knowndevice` endpoint Added a new endpoint which the currently beta client for at least Android v2022.10.1 seems to be calling, and crashes with the response we currently provide Fixes #2890 Fixes #2891 Fixes #2892 --- src/api/core/accounts.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs index 054abf6c..03be4c41 100644 --- a/src/api/core/accounts.rs +++ b/src/api/core/accounts.rs @@ -36,6 +36,7 @@ pub fn routes() -> Vec { verify_password, api_key, rotate_api_key, + get_known_device, ] } @@ -739,3 +740,16 @@ async fn api_key(data: JsonUpcase, headers: Headers, async fn rotate_api_key(data: JsonUpcase, headers: Headers, conn: DbConn) -> JsonResult { _api_key(data, true, headers, conn).await } + +#[get("/devices/knowndevice//")] +async fn get_known_device(email: String, uuid: String, mut conn: DbConn) -> String { + // This endpoint doesn't have auth header + if let Some(user) = User::find_by_mail(&email, &mut conn).await { + match Device::find_by_uuid_and_user(&uuid, &user.uuid, &mut conn).await { + Some(_) => String::from("true"), + _ => String::from("false"), + } + } else { + String::from("false") + } +}