[fractal] Remove the use of rand feature in ruma-identifiers
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] Remove the use of rand feature in ruma-identifiers
- Date: Mon, 7 Sep 2020 06:07:56 +0000 (UTC)
commit a0edee81e148cfc4d82664fdd213644cbfa4c176
Author: Alejandro DomÃnguez <adomu net-c com>
Date: Tue Aug 25 11:19:29 2020 +0200
Remove the use of rand feature in ruma-identifiers
Cargo.lock | 1 -
fractal-gtk/src/appop/room.rs | 31 ++++---------------------------
fractal-gtk/src/appop/start_chat.rs | 28 +---------------------------
fractal-gtk/src/backend/directory.rs | 2 +-
fractal-matrix-api/Cargo.toml | 7 ++-----
5 files changed, 8 insertions(+), 61 deletions(-)
---
diff --git a/Cargo.lock b/Cargo.lock
index ca899b0e..456130b6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2389,7 +2389,6 @@ version = "0.17.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5917092ecf88dec0a9a1f39ed5755096f39dc23003dcc278a58805ee8be65dee"
dependencies = [
- "rand 0.7.3",
"ruma-identifiers-macros",
"ruma-identifiers-validation",
"serde",
diff --git a/fractal-gtk/src/appop/room.rs b/fractal-gtk/src/appop/room.rs
index 07eeb676..970588cb 100644
--- a/fractal-gtk/src/appop/room.rs
+++ b/fractal-gtk/src/appop/room.rs
@@ -1,10 +1,9 @@
use crate::backend::room;
use crate::i18n::{i18n, i18n_k, ni18n_f};
-use fractal_api::identifiers::{DeviceId, RoomId, ServerName};
-use fractal_api::r0::HostAndPort;
+use fractal_api::identifiers::{DeviceId, RoomId};
use fractal_api::url::Url;
use log::{error, warn};
-use std::convert::{TryFrom, TryInto};
+use std::convert::TryInto;
use std::fs::remove_file;
use std::os::unix::fs;
use std::thread;
@@ -394,13 +393,6 @@ impl AppOp {
room::RoomType::Public
};
- let server_name: Box<ServerName> = HostAndPort::try_from(&login_data.server_url)
- .expect("The server domain should have been validated")
- .to_string()
- .try_into()
- .expect("A host with an optional port should always be a valid Matrix server name");
- let internal_id = RoomId::new(&server_name);
- let int_id = internal_id.clone();
let name = n.clone();
thread::spawn(move || {
match room::new_room(
@@ -410,24 +402,13 @@ impl AppOp {
privacy,
) {
Ok(r) => {
- let id = Some(int_id);
- APPOP!(new_room, (r, id));
+ APPOP!(new_room, (r));
}
Err(err) => {
- APPOP!(remove_room, (int_id));
err.handle_error();
}
}
});
-
- let fakeroom = Room {
- name: Some(n),
- ..Room::new(internal_id.clone(), RoomMembership::Joined(RoomTag::None))
- };
-
- self.new_room(fakeroom, None);
- self.set_active_room_by_id(internal_id);
- self.set_state(AppState::Room);
}
pub fn cache_rooms(&self) {
@@ -587,11 +568,7 @@ impl AppOp {
});
}
- pub fn new_room(&mut self, r: Room, internal_id: Option<RoomId>) {
- if let Some(id) = internal_id {
- self.remove_room(id);
- }
-
+ pub fn new_room(&mut self, r: Room) {
if !self.rooms.contains_key(&r.id) {
self.rooms.insert(r.id.clone(), r.clone());
}
diff --git a/fractal-gtk/src/appop/start_chat.rs b/fractal-gtk/src/appop/start_chat.rs
index e6651a06..c19a861a 100644
--- a/fractal-gtk/src/appop/start_chat.rs
+++ b/fractal-gtk/src/appop/start_chat.rs
@@ -1,18 +1,12 @@
use crate::backend::room;
-use fractal_api::identifiers::{RoomId, ServerName};
-use fractal_api::r0::HostAndPort;
use gtk::prelude::*;
-use std::convert::{TryFrom, TryInto};
use std::thread;
-use crate::actions::AppState;
use crate::app::App;
use crate::appop::AppOp;
use crate::appop::SearchType;
use crate::backend::HandleError;
-use crate::types::{Room, RoomMembership, RoomTag};
-
impl AppOp {
pub fn start_chat(&mut self) {
if self.invite_list.len() != 1 {
@@ -22,14 +16,6 @@ impl AppOp {
let login_data = unwrap_or_unit_return!(self.login_data.clone());
let user = self.invite_list[0].clone();
- let server_name: Box<ServerName> = HostAndPort::try_from(&login_data.server_url)
- .expect("The server domain should have been validated")
- .to_string()
- .try_into()
- .expect("A host with an optional port should always be a valid Matrix server name");
- let internal_id = RoomId::new(&server_name);
-
- let int_id = internal_id.clone();
let member = user.0.clone();
thread::spawn(move || {
match room::direct_chat(
@@ -39,27 +25,15 @@ impl AppOp {
member,
) {
Ok(r) => {
- let id = Some(int_id);
- APPOP!(new_room, (r, id));
+ APPOP!(new_room, (r));
}
Err(err) => {
- APPOP!(remove_room, (int_id));
err.handle_error();
}
}
});
self.close_direct_chat_dialog();
-
- let fakeroom = Room {
- name: user.0.alias,
- direct: true,
- ..Room::new(internal_id.clone(), RoomMembership::Joined(RoomTag::None))
- };
-
- self.new_room(fakeroom, None);
- self.set_active_room_by_id(internal_id);
- self.set_state(AppState::Room);
}
pub fn show_direct_chat_dialog(&mut self) {
diff --git a/fractal-gtk/src/backend/directory.rs b/fractal-gtk/src/backend/directory.rs
index 68da99aa..69adc9e5 100644
--- a/fractal-gtk/src/backend/directory.rs
+++ b/fractal-gtk/src/backend/directory.rs
@@ -86,7 +86,7 @@ impl HandleError for DirectorySearchError {
pub fn room_search(
base: Url,
access_token: AccessToken,
- homeserver: String, // TODO: Option<Use HostAndPort>?
+ homeserver: String,
generic_search_term: String,
third_party: String,
rooms_since: Option<String>,
diff --git a/fractal-matrix-api/Cargo.toml b/fractal-matrix-api/Cargo.toml
index 3512fe24..c4353a97 100644
--- a/fractal-matrix-api/Cargo.toml
+++ b/fractal-matrix-api/Cargo.toml
@@ -16,12 +16,9 @@ repository = "https://gitlab.gnome.org/GNOME/fractal"
documentation = "https://gnome.pages.gitlab.gnome.org/fractal/fractal_matrix_api/index.html"
[dependencies]
-serde_json = "1.0.48"
gio = "0.9.0"
-
-[dependencies.ruma-identifiers]
-version = "0.17.1"
-features = ["rand"]
+ruma-identifiers = "0.17.1"
+serde_json = "1.0.48"
[dependencies.serde]
version = "1.0.104"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]