Update Ruma crates dependencies

This commit is contained in:
Lieuwe Rooijakkers 2020-08-04 19:53:38 +02:00 committed by GitHub
parent d42852e1a3
commit fab0ef566f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 26 deletions

View File

@ -21,10 +21,11 @@ futures-util = "0.3.5"
http = "0.2.1"
hyper = "0.13.5"
hyper-tls = { version = "0.4.1", optional = true }
ruma-api = "0.16.1"
ruma-client-api = "0.9.0"
ruma-events = "0.21.2"
ruma-identifiers = "0.16.1"
ruma-api = "=0.17.0-alpha.1"
ruma-client-api = "=0.10.0-alpha.1"
ruma-common = "0.2.0"
ruma-events = "=0.22.0-alpha.1"
ruma-identifiers = "0.17.1"
serde = { version = "1.0.110", features = ["derive"] }
serde_json = "1.0.53"
serde_urlencoded = "0.6.1"

View File

@ -39,8 +39,7 @@ async fn hello_world(homeserver_url: Url, room: String) -> anyhow::Result<()> {
txn_id: "1".to_owned(),
data: to_raw_json_value(&MessageEventContent::Text(TextMessageEventContent {
body: "Hello World!".to_owned(),
format: None,
formatted_body: None,
formatted: None,
relates_to: None,
}))?,
})

View File

@ -3,13 +3,11 @@ use std::{env, process::exit, time::Duration};
use futures_util::stream::{StreamExt as _, TryStreamExt as _};
use ruma_client::{
self,
api::r0::sync::sync_events::SetPresence,
events::{
collections::all::RoomEvent,
room::message::{MessageEvent, MessageEventContent, TextMessageEventContent},
},
events::room::message::{MessageEventContent, TextMessageEventContent},
HttpClient,
};
use ruma_common::presence::PresenceState;
use ruma_events::{AnySyncMessageEvent, AnySyncRoomEvent, SyncMessageEvent};
use url::Url;
async fn log_messages(
@ -26,7 +24,7 @@ async fn log_messages(
.sync(
None,
None,
SetPresence::Online,
PresenceState::Online,
Some(Duration::from_secs(30)),
)
// TODO: This is a horrible way to obtain an initial next_batch token that generates way
@ -44,12 +42,16 @@ async fn log_messages(
.flat_map(|r| r.deserialize())
{
// Filter out the text messages
if let RoomEvent::RoomMessage(MessageEvent {
content:
MessageEventContent::Text(TextMessageEventContent { body: msg_body, .. }),
sender,
..
}) = event
if let AnySyncRoomEvent::Message(AnySyncMessageEvent::RoomMessage(
SyncMessageEvent {
content:
MessageEventContent::Text(TextMessageEventContent {
body: msg_body, ..
}),
sender,
..
},
)) = event
{
println!("{:?} in {:?}: {}", sender, room_id, msg_body);
}

View File

@ -45,7 +45,8 @@
//! use std::time::Duration;
//!
//! # use futures_util::stream::{StreamExt as _, TryStreamExt as _};
//! # use ruma_client::{api::r0::sync::sync_events::SetPresence, Client};
//! # use ruma_client::Client;
//! # use ruma_common::presence::PresenceState;
//! # let homeserver_url = "https://example.com".parse().unwrap();
//! # let client = Client::https(homeserver_url, None);
//! # let next_batch_token = String::new();
@ -53,7 +54,7 @@
//! let mut sync_stream = Box::pin(client.sync(
//! None,
//! Some(next_batch_token),
//! SetPresence::Online,
//! PresenceState::Online,
//! Some(Duration::from_secs(30)),
//! ));
//! while let Some(response) = sync_stream.try_next().await? {
@ -219,7 +220,7 @@ where
&self,
user: String,
password: String,
device_id: Option<DeviceId>,
device_id: Option<Box<DeviceId>>,
initial_device_display_name: Option<String>,
) -> Result<Session, Error<api::Error>> {
use api::r0::session::login;
@ -329,7 +330,7 @@ where
&self,
filter: Option<api::r0::sync::sync_events::Filter>,
since: Option<String>,
set_presence: api::r0::sync::sync_events::SetPresence,
set_presence: ruma_common::presence::PresenceState,
timeout: Option<Duration>,
) -> impl Stream<Item = Result<api::r0::sync::sync_events::Response, Error<api::Error>>>
+ TryStream<Ok = api::r0::sync::sync_events::Response, Error = Error<api::Error>> {

View File

@ -1,6 +1,6 @@
//! User sessions.
use ruma_identifiers::UserId;
use ruma_identifiers::{DeviceId, UserId};
/// A user session, containing an access token and information about the associated user account.
#[derive(Clone, Debug, serde::Deserialize, Eq, Hash, PartialEq, serde::Serialize)]
@ -18,13 +18,13 @@ pub struct Identification {
/// The user the access token was issued for.
pub user_id: UserId,
/// The ID of the client device
pub device_id: String,
pub device_id: Box<DeviceId>,
}
impl Session {
/// Create a new user session from an access token and a user ID.
#[deprecated]
pub fn new(access_token: String, user_id: UserId, device_id: String) -> Self {
pub fn new(access_token: String, user_id: UserId, device_id: Box<DeviceId>) -> Self {
Self {
access_token,
identification: Some(Identification { user_id, device_id }),
@ -48,7 +48,7 @@ impl Session {
/// Get ID of the device the session belongs to.
#[deprecated]
pub fn device_id(&self) -> Option<&str> {
pub fn device_id(&self) -> Option<&DeviceId> {
if let Some(identification) = &self.identification {
return Some(&identification.device_id);
}