[fractal] Revert "API: Use UserId from ruma-identifiers for stronger validation"
- From: Alexandre Franke <afranke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] Revert "API: Use UserId from ruma-identifiers for stronger validation"
- Date: Sat, 23 Nov 2019 09:21:49 +0000 (UTC)
commit 15a66e69ab43efec022b758a1d6eab725d737b1d
Author: Alejandro DomÃnguez <adomu net-c com>
Date: Sat Nov 23 01:10:21 2019 +0100
Revert "API: Use UserId from ruma-identifiers for stronger validation"
This reverts commit 7b4937e4bd2b2652aec7cdc9faae6bd179413a27. Fixes #554.
fractal-matrix-api/src/backend/register.rs | 16 ++++++----------
fractal-matrix-api/src/lib.rs | 1 -
fractal-matrix-api/src/model/member.rs | 2 +-
fractal-matrix-api/src/r0/account/login.rs | 3 +--
fractal-matrix-api/src/r0/account/register.rs | 3 +--
fractal-matrix-api/src/r0/search/user.rs | 3 +--
fractal-matrix-api/src/r0/sync/sync_events.rs | 5 ++---
7 files changed, 12 insertions(+), 21 deletions(-)
---
diff --git a/fractal-matrix-api/src/backend/register.rs b/fractal-matrix-api/src/backend/register.rs
index 7975ecf8..db9b81e3 100644
--- a/fractal-matrix-api/src/backend/register.rs
+++ b/fractal-matrix-api/src/backend/register.rs
@@ -49,13 +49,13 @@ pub fn guest(bk: &Backend, base: Url) {
match query {
Ok(response) => {
- let uid = response.user_id.to_string();
+ let uid = response.user_id;
let tk = response.access_token;
let dev = response.device_id;
data.lock().unwrap().user_id = uid.clone();
data.lock().unwrap().since = None;
- tx.send(BKResponse::Token(uid, tk, dev)) // TODO: Use UserId and DeviceId
+ tx.send(BKResponse::Token(uid, tk, dev))
.expect_log("Connection closed");
tx.send(BKResponse::Rooms(vec![], None))
.expect_log("Connection closed");
@@ -104,11 +104,7 @@ pub fn login(bk: &Backend, user: String, password: String, base: Url) {
match query {
Ok(response) => {
- let uid = response
- .user_id
- .as_ref()
- .map(ToString::to_string)
- .unwrap_or(user);
+ let uid = response.user_id.unwrap_or(user);
let tk = response.access_token;
let dev = response.device_id;
@@ -118,7 +114,7 @@ pub fn login(bk: &Backend, user: String, password: String, base: Url) {
} else {
data.lock().unwrap().user_id = uid.clone();
data.lock().unwrap().since = None;
- tx.send(BKResponse::Token(uid, tk, dev)) // TODO: Use UserId and DeviceId
+ tx.send(BKResponse::Token(uid, tk, dev))
.expect_log("Connection closed");
}
}
@@ -189,13 +185,13 @@ pub fn register(bk: &Backend, user: String, password: String, base: Url) {
match query {
Ok(response) => {
- let uid = response.user_id.to_string();
+ let uid = response.user_id;
let tk = response.access_token;
let dev = response.device_id;
data.lock().unwrap().user_id = uid.clone();
data.lock().unwrap().since = None;
- tx.send(BKResponse::Token(uid, tk, dev)) // TODO: Use UserId
+ tx.send(BKResponse::Token(uid, tk, dev))
.expect_log("Connection closed");
}
Err(err) => {
diff --git a/fractal-matrix-api/src/lib.rs b/fractal-matrix-api/src/lib.rs
index fff5f0d1..0999b0af 100644
--- a/fractal-matrix-api/src/lib.rs
+++ b/fractal-matrix-api/src/lib.rs
@@ -16,7 +16,6 @@ pub mod prelude {
pub use ruma_identifiers::DeviceId;
pub use ruma_identifiers::RoomAliasId;
pub use ruma_identifiers::RoomId;
- pub use ruma_identifiers::UserId;
}
#[cfg(test)]
diff --git a/fractal-matrix-api/src/model/member.rs b/fractal-matrix-api/src/model/member.rs
index bc9915e7..3f9ae5cd 100644
--- a/fractal-matrix-api/src/model/member.rs
+++ b/fractal-matrix-api/src/model/member.rs
@@ -36,7 +36,7 @@ impl PartialEq for Member {
impl From<User> for Member {
fn from(user: User) -> Self {
Self {
- uid: user.user_id.to_string(),
+ uid: user.user_id,
alias: user.display_name,
avatar: user.avatar_url.map(Url::into_string),
}
diff --git a/fractal-matrix-api/src/r0/account/login.rs b/fractal-matrix-api/src/r0/account/login.rs
index 14f3bfcc..28f1f617 100644
--- a/fractal-matrix-api/src/r0/account/login.rs
+++ b/fractal-matrix-api/src/r0/account/login.rs
@@ -4,7 +4,6 @@ use reqwest::Client;
use reqwest::Error;
use reqwest::Request;
use ruma_identifiers::DeviceId;
-use ruma_identifiers::UserId;
use serde::{Deserialize, Serialize};
use url::Url;
@@ -32,7 +31,7 @@ pub enum Auth {
#[derive(Clone, Debug, Deserialize)]
pub struct Response {
pub access_token: Option<AccessToken>,
- pub user_id: Option<UserId>,
+ pub user_id: Option<String>,
pub device_id: Option<DeviceId>,
}
diff --git a/fractal-matrix-api/src/r0/account/register.rs b/fractal-matrix-api/src/r0/account/register.rs
index c072f24c..5c01a7f1 100644
--- a/fractal-matrix-api/src/r0/account/register.rs
+++ b/fractal-matrix-api/src/r0/account/register.rs
@@ -4,7 +4,6 @@ use reqwest::Client;
use reqwest::Error;
use reqwest::Request;
use ruma_identifiers::DeviceId;
-use ruma_identifiers::UserId;
use serde::{Deserialize, Serialize};
use std::ops::Not;
use url::Url;
@@ -55,7 +54,7 @@ pub struct Body {
#[derive(Clone, Debug, Deserialize)]
pub struct Response {
- pub user_id: UserId,
+ pub user_id: String,
pub access_token: Option<AccessToken>,
pub device_id: Option<DeviceId>,
}
diff --git a/fractal-matrix-api/src/r0/search/user.rs b/fractal-matrix-api/src/r0/search/user.rs
index af5191c8..2fc55367 100644
--- a/fractal-matrix-api/src/r0/search/user.rs
+++ b/fractal-matrix-api/src/r0/search/user.rs
@@ -3,7 +3,6 @@ use crate::serde::option_url;
use reqwest::Client;
use reqwest::Error;
use reqwest::Request;
-use ruma_identifiers::UserId;
use serde::{Deserialize, Serialize};
use url::Url;
@@ -36,7 +35,7 @@ pub struct Response {
#[derive(Clone, Debug, Deserialize)]
pub struct User {
- pub user_id: UserId,
+ pub user_id: String,
#[serde(default)]
pub display_name: Option<String>,
#[serde(with = "option_url")]
diff --git a/fractal-matrix-api/src/r0/sync/sync_events.rs b/fractal-matrix-api/src/r0/sync/sync_events.rs
index ebd658d2..e23c3298 100644
--- a/fractal-matrix-api/src/r0/sync/sync_events.rs
+++ b/fractal-matrix-api/src/r0/sync/sync_events.rs
@@ -4,7 +4,6 @@ use crate::serde::duration_as_millis;
use reqwest::Client;
use reqwest::Error;
use reqwest::Request;
-use ruma_identifiers::UserId;
use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue;
use std::collections::HashMap;
@@ -184,9 +183,9 @@ pub struct ToDevice {
#[derive(Clone, Debug, Deserialize)]
pub struct DeviceLists {
#[serde(default)]
- pub changed: Vec<UserId>,
+ pub changed: Vec<String>,
#[serde(default)]
- pub left: Vec<UserId>,
+ pub left: Vec<String>,
}
pub fn request(base: Url, params: &Parameters) -> Result<Request, Error> {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]