Commit bea2e3f5ba

bea2e3f5ba2f79eca8abdce49df42b84675b1261

parent: 4baa1e6134

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2020-03-28 11:28 UTC

server: Update to the latest rust-sdk changes.

Layout: unified · split

Cargo.toml +2 −3
@@ -10,7 +10,7 @@ name = "matrix"
10crate-type = ["dylib"] 10crate-type = ["dylib"]
11 11
12[dependencies] 12[dependencies]
13libc = "0.2.67" 13libc = "0.2.68"
14url = "2.1.1" 14url = "2.1.1"
15tokio = { version = "0.2.13", features = [ "rt-threaded" ] } 15tokio = { version = "0.2.13", features = [ "rt-threaded" ] }
16async-std = { version = "1.5.0", features = [ "unstable" ] } 16async-std = { version = "1.5.0", features = [ "unstable" ] }
@@ -21,6 +21,5 @@ weechat-sys = { git = "https://github.com/poljar/rust-weechat" }
21 21
22[dependencies.matrix-sdk] 22[dependencies.matrix-sdk]
23git = "https://github.com/matrix-org/matrix-rust-sdk/" 23git = "https://github.com/matrix-org/matrix-rust-sdk/"
24branch = "encryption"
25default-features = false 24default-features = false
26features = ["encryption"] 25features = ["encryption", "sqlite-cryptostore"]
src/server.rs +4 −4
@@ -54,6 +54,7 @@ use async_std::sync::channel as async_channel;
54use async_std::sync::{Receiver, Sender}; 54use async_std::sync::{Receiver, Sender};
55use std::cell::RefCell; 55use std::cell::RefCell;
56use std::collections::HashMap; 56use std::collections::HashMap;
57use std::time::Duration;
57use std::rc::{Rc, Weak}; 58use std::rc::{Rc, Weak};
58use tokio::runtime::Runtime; 59use tokio::runtime::Runtime;
59use url::Url; 60use url::Url;
@@ -80,7 +81,7 @@ use crate::room_buffer::RoomBuffer;
80use crate::Config; 81use crate::Config;
81use crate::PLUGIN_NAME; 82use crate::PLUGIN_NAME;
82 83
83const DEFAULT_SYNC_TIMEOUT: i32 = 30000; 84const DEFAULT_SYNC_TIMEOUT: Duration = Duration::from_secs(30);
84 85
85pub enum ThreadMessage { 86pub enum ThreadMessage {
86 LoginMessage(LoginResponse), 87 LoginMessage(LoginResponse),
@@ -526,7 +527,7 @@ impl MatrixServer {
526 password: String, 527 password: String,
527 ) { 528 ) {
528 if !client.logged_in().await { 529 if !client.logged_in().await {
529 let ret = client.login(username, password, None).await; 530 let ret = client.login(username, password, None, Some("Weechat-Matrix".to_owned())).await;
530 531
531 match ret { 532 match ret {
532 Ok(response) => { 533 Ok(response) => {
@@ -543,8 +544,7 @@ impl MatrixServer {
543 544
544 let sync_token = client.sync_token().await; 545 let sync_token = client.sync_token().await;
545 let sync_settings = SyncSettings::new() 546 let sync_settings = SyncSettings::new()
546 .timeout(DEFAULT_SYNC_TIMEOUT) 547 .timeout(DEFAULT_SYNC_TIMEOUT);
547 .expect("Invalid sync timeout");
548 548
549 let sync_settings = if let Some(t) = sync_token { 549 let sync_settings = if let Some(t) = sync_token {
550 sync_settings.token(t) 550 sync_settings.token(t)