[fractal] Backend: Use Url type in BackendData.scalar_url
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] Backend: Use Url type in BackendData.scalar_url
- Date: Sun, 13 Jan 2019 11:39:36 +0000 (UTC)
commit 63b83d5e0ea2f0e1e033e317acb6b455b92a41f2
Author: Alejandro DomÃnguez <adomu net-c com>
Date: Sun Dec 30 01:06:44 2018 +0100
Backend: Use Url type in BackendData.scalar_url
fractal-matrix-api/src/backend/mod.rs | 3 ++-
fractal-matrix-api/src/backend/stickers.rs | 7 +++----
fractal-matrix-api/src/backend/types.rs | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/fractal-matrix-api/src/backend/mod.rs b/fractal-matrix-api/src/backend/mod.rs
index acbffab3..326f329a 100644
--- a/fractal-matrix-api/src/backend/mod.rs
+++ b/fractal-matrix-api/src/backend/mod.rs
@@ -37,7 +37,8 @@ impl Backend {
server_url: Url::parse("https://matrix.org")
.expect("Wrong server_url value in BackendData"),
scalar_token: None,
- scalar_url: String::from("https://scalar.vector.im"),
+ scalar_url: Url::parse("https://scalar.vector.im")
+ .expect("Wrong scalar_url value in BackendData"),
sticker_widget: None,
since: None,
rooms_since: String::new(),
diff --git a/fractal-matrix-api/src/backend/stickers.rs b/fractal-matrix-api/src/backend/stickers.rs
index d9781db7..67dc71df 100644
--- a/fractal-matrix-api/src/backend/stickers.rs
+++ b/fractal-matrix-api/src/backend/stickers.rs
@@ -184,13 +184,13 @@ fn url(
}
fn get_scalar_token(data: &Arc<Mutex<BackendData>>) -> Result<String, Error> {
- let s = data.lock().unwrap().scalar_url.clone();
+ let base = data.lock().unwrap().scalar_url.clone();
let uid = data.lock().unwrap().user_id.clone();
let url = url(data, &format!("user/{}/openid/request_token", uid), vec![])?;
let js = json_q("post", &url, &json!({}), globals::TIMEOUT)?;
- let vurl = Url::parse(&format!("{}/api/register", s))?;
+ let vurl = base.join("/api/register")?;
let js = json_q("post", &vurl, &js, globals::TIMEOUT)?;
match js["scalar_token"].as_str() {
@@ -207,8 +207,7 @@ fn vurl(
path: &str,
mut params: Vec<(&str, String)>,
) -> Result<Url, Error> {
- let s = data.lock().unwrap().scalar_url.clone();
- let base = Url::parse(&s)?;
+ let base = data.lock().unwrap().scalar_url.clone();
let token = data.lock().unwrap().scalar_token.clone();
let tk = match token {
None => get_scalar_token(&data)?,
diff --git a/fractal-matrix-api/src/backend/types.rs b/fractal-matrix-api/src/backend/types.rs
index 1a960380..73d8e0eb 100644
--- a/fractal-matrix-api/src/backend/types.rs
+++ b/fractal-matrix-api/src/backend/types.rs
@@ -188,7 +188,7 @@ pub struct BackendData {
pub access_token: String,
pub server_url: Url,
pub scalar_token: Option<String>,
- pub scalar_url: String,
+ pub scalar_url: Url,
pub sticker_widget: Option<String>,
pub since: Option<String>,
pub rooms_since: String,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]