[fractal] API: use global variable for device name



commit 2d8e9764e387a2f6023eb545838b49406232dcac
Author: Alejandro Domínguez <adomu net-c com>
Date:   Tue Feb 5 19:01:17 2019 +0100

    API: use global variable for device name

 fractal-matrix-api/src/backend/register.rs | 7 ++++++-
 fractal-matrix-api/src/globals.rs          | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/fractal-matrix-api/src/backend/register.rs b/fractal-matrix-api/src/backend/register.rs
index 26cfdf40..d4e465bb 100644
--- a/fractal-matrix-api/src/backend/register.rs
+++ b/fractal-matrix-api/src/backend/register.rs
@@ -55,7 +55,12 @@ pub fn login(bk: &Backend, user: String, password: String, server: &str) -> Resu
     bk.data.lock().unwrap().server_url = Url::parse(server)?;
     let url = bk.url("login", vec![])?;
 
-    let attrs = LoginRequest::new(user.clone(), password, Some(String::from("Fractal")), None);
+    let attrs = LoginRequest::new(
+        user.clone(),
+        password,
+        Some(globals::DEVICE_NAME.into()),
+        None,
+    );
     let attrs_json = serde_json::to_value(attrs).expect("Failed to serialize login request");
     let data = bk.data.clone();
 
diff --git a/fractal-matrix-api/src/globals.rs b/fractal-matrix-api/src/globals.rs
index 30852f5c..327d65c8 100644
--- a/fractal-matrix-api/src/globals.rs
+++ b/fractal-matrix-api/src/globals.rs
@@ -5,6 +5,7 @@ pub static TIMEOUT: u64 = 80;
 pub static PAGE_LIMIT: i32 = 40;
 pub static ROOM_DIRECTORY_LIMIT: i32 = 20;
 pub static THUMBNAIL_SIZE: i32 = 128;
+pub static DEVICE_NAME: &str = "Fractal";
 
 lazy_static! {
     pub static ref MATRIX_RE: Regex = Regex::new(r"mxc://(?P<server>[^/]+)/(?P<media>.+)").unwrap();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]