Update Ruma crates dependencies
This commit is contained in:
parent
d42852e1a3
commit
fab0ef566f
@ -21,10 +21,11 @@ futures-util = "0.3.5"
|
|||||||
http = "0.2.1"
|
http = "0.2.1"
|
||||||
hyper = "0.13.5"
|
hyper = "0.13.5"
|
||||||
hyper-tls = { version = "0.4.1", optional = true }
|
hyper-tls = { version = "0.4.1", optional = true }
|
||||||
ruma-api = "0.16.1"
|
ruma-api = "=0.17.0-alpha.1"
|
||||||
ruma-client-api = "0.9.0"
|
ruma-client-api = "=0.10.0-alpha.1"
|
||||||
ruma-events = "0.21.2"
|
ruma-common = "0.2.0"
|
||||||
ruma-identifiers = "0.16.1"
|
ruma-events = "=0.22.0-alpha.1"
|
||||||
|
ruma-identifiers = "0.17.1"
|
||||||
serde = { version = "1.0.110", features = ["derive"] }
|
serde = { version = "1.0.110", features = ["derive"] }
|
||||||
serde_json = "1.0.53"
|
serde_json = "1.0.53"
|
||||||
serde_urlencoded = "0.6.1"
|
serde_urlencoded = "0.6.1"
|
||||||
|
@ -39,8 +39,7 @@ async fn hello_world(homeserver_url: Url, room: String) -> anyhow::Result<()> {
|
|||||||
txn_id: "1".to_owned(),
|
txn_id: "1".to_owned(),
|
||||||
data: to_raw_json_value(&MessageEventContent::Text(TextMessageEventContent {
|
data: to_raw_json_value(&MessageEventContent::Text(TextMessageEventContent {
|
||||||
body: "Hello World!".to_owned(),
|
body: "Hello World!".to_owned(),
|
||||||
format: None,
|
formatted: None,
|
||||||
formatted_body: None,
|
|
||||||
relates_to: None,
|
relates_to: None,
|
||||||
}))?,
|
}))?,
|
||||||
})
|
})
|
||||||
|
@ -3,13 +3,11 @@ use std::{env, process::exit, time::Duration};
|
|||||||
use futures_util::stream::{StreamExt as _, TryStreamExt as _};
|
use futures_util::stream::{StreamExt as _, TryStreamExt as _};
|
||||||
use ruma_client::{
|
use ruma_client::{
|
||||||
self,
|
self,
|
||||||
api::r0::sync::sync_events::SetPresence,
|
events::room::message::{MessageEventContent, TextMessageEventContent},
|
||||||
events::{
|
|
||||||
collections::all::RoomEvent,
|
|
||||||
room::message::{MessageEvent, MessageEventContent, TextMessageEventContent},
|
|
||||||
},
|
|
||||||
HttpClient,
|
HttpClient,
|
||||||
};
|
};
|
||||||
|
use ruma_common::presence::PresenceState;
|
||||||
|
use ruma_events::{AnySyncMessageEvent, AnySyncRoomEvent, SyncMessageEvent};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
async fn log_messages(
|
async fn log_messages(
|
||||||
@ -26,7 +24,7 @@ async fn log_messages(
|
|||||||
.sync(
|
.sync(
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
SetPresence::Online,
|
PresenceState::Online,
|
||||||
Some(Duration::from_secs(30)),
|
Some(Duration::from_secs(30)),
|
||||||
)
|
)
|
||||||
// TODO: This is a horrible way to obtain an initial next_batch token that generates way
|
// 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())
|
.flat_map(|r| r.deserialize())
|
||||||
{
|
{
|
||||||
// Filter out the text messages
|
// Filter out the text messages
|
||||||
if let RoomEvent::RoomMessage(MessageEvent {
|
if let AnySyncRoomEvent::Message(AnySyncMessageEvent::RoomMessage(
|
||||||
content:
|
SyncMessageEvent {
|
||||||
MessageEventContent::Text(TextMessageEventContent { body: msg_body, .. }),
|
content:
|
||||||
sender,
|
MessageEventContent::Text(TextMessageEventContent {
|
||||||
..
|
body: msg_body, ..
|
||||||
}) = event
|
}),
|
||||||
|
sender,
|
||||||
|
..
|
||||||
|
},
|
||||||
|
)) = event
|
||||||
{
|
{
|
||||||
println!("{:?} in {:?}: {}", sender, room_id, msg_body);
|
println!("{:?} in {:?}: {}", sender, room_id, msg_body);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,8 @@
|
|||||||
//! use std::time::Duration;
|
//! use std::time::Duration;
|
||||||
//!
|
//!
|
||||||
//! # use futures_util::stream::{StreamExt as _, TryStreamExt as _};
|
//! # 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 homeserver_url = "https://example.com".parse().unwrap();
|
||||||
//! # let client = Client::https(homeserver_url, None);
|
//! # let client = Client::https(homeserver_url, None);
|
||||||
//! # let next_batch_token = String::new();
|
//! # let next_batch_token = String::new();
|
||||||
@ -53,7 +54,7 @@
|
|||||||
//! let mut sync_stream = Box::pin(client.sync(
|
//! let mut sync_stream = Box::pin(client.sync(
|
||||||
//! None,
|
//! None,
|
||||||
//! Some(next_batch_token),
|
//! Some(next_batch_token),
|
||||||
//! SetPresence::Online,
|
//! PresenceState::Online,
|
||||||
//! Some(Duration::from_secs(30)),
|
//! Some(Duration::from_secs(30)),
|
||||||
//! ));
|
//! ));
|
||||||
//! while let Some(response) = sync_stream.try_next().await? {
|
//! while let Some(response) = sync_stream.try_next().await? {
|
||||||
@ -219,7 +220,7 @@ where
|
|||||||
&self,
|
&self,
|
||||||
user: String,
|
user: String,
|
||||||
password: String,
|
password: String,
|
||||||
device_id: Option<DeviceId>,
|
device_id: Option<Box<DeviceId>>,
|
||||||
initial_device_display_name: Option<String>,
|
initial_device_display_name: Option<String>,
|
||||||
) -> Result<Session, Error<api::Error>> {
|
) -> Result<Session, Error<api::Error>> {
|
||||||
use api::r0::session::login;
|
use api::r0::session::login;
|
||||||
@ -329,7 +330,7 @@ where
|
|||||||
&self,
|
&self,
|
||||||
filter: Option<api::r0::sync::sync_events::Filter>,
|
filter: Option<api::r0::sync::sync_events::Filter>,
|
||||||
since: Option<String>,
|
since: Option<String>,
|
||||||
set_presence: api::r0::sync::sync_events::SetPresence,
|
set_presence: ruma_common::presence::PresenceState,
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
) -> impl Stream<Item = Result<api::r0::sync::sync_events::Response, Error<api::Error>>>
|
) -> 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>> {
|
+ TryStream<Ok = api::r0::sync::sync_events::Response, Error = Error<api::Error>> {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! User sessions.
|
//! 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.
|
/// A user session, containing an access token and information about the associated user account.
|
||||||
#[derive(Clone, Debug, serde::Deserialize, Eq, Hash, PartialEq, serde::Serialize)]
|
#[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.
|
/// The user the access token was issued for.
|
||||||
pub user_id: UserId,
|
pub user_id: UserId,
|
||||||
/// The ID of the client device
|
/// The ID of the client device
|
||||||
pub device_id: String,
|
pub device_id: Box<DeviceId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Session {
|
impl Session {
|
||||||
/// Create a new user session from an access token and a user ID.
|
/// Create a new user session from an access token and a user ID.
|
||||||
#[deprecated]
|
#[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 {
|
Self {
|
||||||
access_token,
|
access_token,
|
||||||
identification: Some(Identification { user_id, device_id }),
|
identification: Some(Identification { user_id, device_id }),
|
||||||
@ -48,7 +48,7 @@ impl Session {
|
|||||||
|
|
||||||
/// Get ID of the device the session belongs to.
|
/// Get ID of the device the session belongs to.
|
||||||
#[deprecated]
|
#[deprecated]
|
||||||
pub fn device_id(&self) -> Option<&str> {
|
pub fn device_id(&self) -> Option<&DeviceId> {
|
||||||
if let Some(identification) = &self.identification {
|
if let Some(identification) = &self.identification {
|
||||||
return Some(&identification.device_id);
|
return Some(&identification.device_id);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user