Rename room::Common to Room
… and export it at the matrix_sdk crate root.
This commit is contained in:
committed by
Jonas Platte
parent
db84fcd8da
commit
92df7b22ec
@@ -7,7 +7,7 @@ use matrix_sdk::{
|
||||
AttachmentConfig, AttachmentInfo, BaseAudioInfo, BaseFileInfo, BaseImageInfo,
|
||||
BaseThumbnailInfo, BaseVideoInfo, Thumbnail,
|
||||
},
|
||||
room::{Common as SdkRoom, Receipts},
|
||||
room::{Receipts, Room as SdkRoom},
|
||||
ruma::{
|
||||
api::client::{receipt::create_receipt::v3::ReceiptType, room::report_content},
|
||||
events::{
|
||||
|
||||
@@ -46,7 +46,7 @@ struct RoomInner {
|
||||
sliding_sync_room: SlidingSyncRoom,
|
||||
|
||||
/// The underlying client room.
|
||||
room: matrix_sdk::room::Common,
|
||||
room: matrix_sdk::Room,
|
||||
|
||||
/// The timeline of the room.
|
||||
timeline: AsyncOnceCell<Arc<Timeline>>,
|
||||
@@ -89,8 +89,8 @@ impl Room {
|
||||
})
|
||||
}
|
||||
|
||||
/// Get the underlying [`matrix_sdk::room::Common`].
|
||||
pub fn inner_room(&self) -> &matrix_sdk::room::Common {
|
||||
/// Get the underlying [`matrix_sdk::Room`].
|
||||
pub fn inner_room(&self) -> &matrix_sdk::Room {
|
||||
&self.inner.room
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ use async_std::sync::Mutex;
|
||||
use eyeball::SharedObservable;
|
||||
use imbl::Vector;
|
||||
use matrix_sdk::{
|
||||
deserialized_responses::SyncTimelineEvent, executor::spawn, room, sync::RoomUpdate,
|
||||
deserialized_responses::SyncTimelineEvent, executor::spawn, sync::RoomUpdate, Room,
|
||||
};
|
||||
use ruma::events::{
|
||||
receipt::{ReceiptThread, ReceiptType},
|
||||
@@ -40,14 +40,14 @@ use super::{
|
||||
#[must_use]
|
||||
#[derive(Debug)]
|
||||
pub struct TimelineBuilder {
|
||||
room: room::Common,
|
||||
room: Room,
|
||||
prev_token: Option<String>,
|
||||
events: Vector<SyncTimelineEvent>,
|
||||
settings: TimelineInnerSettings,
|
||||
}
|
||||
|
||||
impl TimelineBuilder {
|
||||
pub(super) fn new(room: &room::Common) -> Self {
|
||||
pub(super) fn new(room: &Room) -> Self {
|
||||
Self {
|
||||
room: room.clone(),
|
||||
prev_token: None,
|
||||
|
||||
@@ -26,9 +26,8 @@ use itertools::Itertools;
|
||||
use matrix_sdk::crypto::OlmMachine;
|
||||
use matrix_sdk::{
|
||||
deserialized_responses::{SyncTimelineEvent, TimelineEvent},
|
||||
room,
|
||||
sync::{JoinedRoom, Timeline},
|
||||
Error, Result,
|
||||
Error, Result, Room,
|
||||
};
|
||||
#[cfg(test)]
|
||||
use ruma::events::receipt::ReceiptEventContent;
|
||||
@@ -74,7 +73,7 @@ use super::{
|
||||
use crate::events::SyncTimelineEventWithoutContent;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(super) struct TimelineInner<P: RoomDataProvider = room::Common> {
|
||||
pub(super) struct TimelineInner<P: RoomDataProvider = Room> {
|
||||
state: Arc<Mutex<TimelineInnerState>>,
|
||||
room_data_provider: P,
|
||||
settings: TimelineInnerSettings,
|
||||
@@ -743,7 +742,7 @@ impl<P: RoomDataProvider> TimelineInner<P> {
|
||||
#[instrument(skip(self, room), fields(room_id = ?room.room_id()))]
|
||||
pub(super) async fn retry_event_decryption(
|
||||
&self,
|
||||
room: &room::Common,
|
||||
room: &Room,
|
||||
session_ids: Option<BTreeSet<String>>,
|
||||
) {
|
||||
self.retry_event_decryption_inner(room.to_owned(), session_ids).await
|
||||
@@ -945,7 +944,7 @@ impl<P: RoomDataProvider> TimelineInner<P> {
|
||||
}
|
||||
|
||||
impl TimelineInner {
|
||||
pub(super) fn room(&self) -> &room::Common {
|
||||
pub(super) fn room(&self) -> &Room {
|
||||
&self.room_data_provider
|
||||
}
|
||||
|
||||
@@ -1254,7 +1253,7 @@ async fn fetch_replied_to_event(
|
||||
item: &EventTimelineItem,
|
||||
message: &Message,
|
||||
in_reply_to: &EventId,
|
||||
room: &room::Common,
|
||||
room: &Room,
|
||||
) -> Result<TimelineDetails<Box<RepliedToEvent>>, super::Error> {
|
||||
if let Some((_, item)) = rfind_event_by_id(&state.items, in_reply_to) {
|
||||
let details = match item.content() {
|
||||
|
||||
@@ -27,7 +27,7 @@ use matrix_sdk::{
|
||||
attachment::AttachmentConfig,
|
||||
event_handler::EventHandlerHandle,
|
||||
executor::JoinHandle,
|
||||
room::{self, MessagesOptions, Receipts},
|
||||
room::{MessagesOptions, Receipts, Room},
|
||||
Client, Result,
|
||||
};
|
||||
use matrix_sdk_base::RoomState;
|
||||
@@ -102,7 +102,7 @@ const DEFAULT_SANITIZER_MODE: HtmlSanitizerMode = HtmlSanitizerMode::Compat;
|
||||
/// messages.
|
||||
#[derive(Debug)]
|
||||
pub struct Timeline {
|
||||
inner: TimelineInner<room::Common>,
|
||||
inner: TimelineInner<Room>,
|
||||
|
||||
start_token: Arc<Mutex<Option<String>>>,
|
||||
start_token_condvar: Arc<Condvar>,
|
||||
@@ -128,11 +128,11 @@ impl From<&Annotation> for AnnotationKey {
|
||||
}
|
||||
|
||||
impl Timeline {
|
||||
pub(crate) fn builder(room: &room::Common) -> TimelineBuilder {
|
||||
pub(crate) fn builder(room: &Room) -> TimelineBuilder {
|
||||
TimelineBuilder::new(room)
|
||||
}
|
||||
|
||||
fn room(&self) -> &room::Common {
|
||||
fn room(&self) -> &Room {
|
||||
self.inner.room()
|
||||
}
|
||||
|
||||
@@ -573,10 +573,9 @@ impl Timeline {
|
||||
|
||||
/// Get the latest read receipt for the given user.
|
||||
///
|
||||
/// Contrary to [`Common::user_receipt()`](room::Common::user_receipt) that
|
||||
/// only keeps track of read receipts received from the homeserver, this
|
||||
/// keeps also track of implicit read receipts in this timeline, i.e.
|
||||
/// when a room member sends an event.
|
||||
/// Contrary to [`Room::user_receipt()`] that only keeps track of read
|
||||
/// receipts received from the homeserver, this keeps also track of implicit
|
||||
/// read receipts in this timeline, i.e. when a room member sends an event.
|
||||
#[instrument(skip(self))]
|
||||
pub async fn latest_user_read_receipt(
|
||||
&self,
|
||||
@@ -587,7 +586,7 @@ impl Timeline {
|
||||
|
||||
/// Send the given receipt.
|
||||
///
|
||||
/// This uses [`room::Common::send_single_receipt`] internally, but checks
|
||||
/// This uses [`Room::send_single_receipt`] internally, but checks
|
||||
/// first if the receipt points to an event in this timeline that is more
|
||||
/// recent than the current ones, to avoid unnecessary requests.
|
||||
#[instrument(skip(self))]
|
||||
@@ -606,7 +605,7 @@ impl Timeline {
|
||||
|
||||
/// Send the given receipts.
|
||||
///
|
||||
/// This uses [`room::Common::send_multiple_receipts`] internally, but
|
||||
/// This uses [`Room::send_multiple_receipts`] internally, but
|
||||
/// checks first if the receipts point to events in this timeline that
|
||||
/// are more recent than the current ones, to avoid unnecessary
|
||||
/// requests.
|
||||
|
||||
@@ -24,7 +24,7 @@ use std::{
|
||||
use futures_util::future::Either;
|
||||
use matrix_sdk::{
|
||||
executor::{spawn, JoinError, JoinHandle},
|
||||
room,
|
||||
Room,
|
||||
};
|
||||
use matrix_sdk_base::RoomState;
|
||||
use ruma::{events::AnyMessageLikeEventContent, OwnedTransactionId};
|
||||
@@ -46,7 +46,7 @@ pub(super) struct LocalMessage {
|
||||
#[instrument(skip_all, fields(room_id = ?room.room_id()))]
|
||||
pub(super) async fn send_queued_messages(
|
||||
timeline_inner: TimelineInner,
|
||||
room: room::Common,
|
||||
room: Room,
|
||||
mut msg_receiver: Receiver<LocalMessage>,
|
||||
) {
|
||||
let mut queue = VecDeque::new();
|
||||
@@ -98,7 +98,7 @@ pub(super) async fn send_queued_messages(
|
||||
|
||||
async fn handle_message(
|
||||
msg: LocalMessage,
|
||||
room: room::Common,
|
||||
room: Room,
|
||||
send_task: &mut SendMessageTask,
|
||||
queue: &mut VecDeque<LocalMessage>,
|
||||
timeline_inner: &TimelineInner,
|
||||
@@ -160,7 +160,7 @@ enum SendMessageResult {
|
||||
Success {
|
||||
/// The joined room object, used to start sending of the next message
|
||||
/// in the queue, if it isn't empty.
|
||||
room: room::Common,
|
||||
room: Room,
|
||||
},
|
||||
/// Sending failed, and the local echo was updated to indicate this.
|
||||
SendingFailed,
|
||||
@@ -186,7 +186,7 @@ enum SendMessageTask {
|
||||
/// The transaction ID of the message that is being sent.
|
||||
txn_id: OwnedTransactionId,
|
||||
/// Handle to the task itself.
|
||||
join_handle: JoinHandle<Option<room::Common>>,
|
||||
join_handle: JoinHandle<Option<Room>>,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ impl SendMessageTask {
|
||||
matches!(self, Self::Idle)
|
||||
}
|
||||
|
||||
fn start(&mut self, room: room::Common, timeline_inner: TimelineInner, msg: LocalMessage) {
|
||||
fn start(&mut self, room: Room, timeline_inner: TimelineInner, msg: LocalMessage) {
|
||||
debug!("Spawning message-sending task");
|
||||
let txn_id = msg.txn_id.clone();
|
||||
let join_handle = spawn(async move {
|
||||
|
||||
@@ -16,7 +16,7 @@ use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use eyeball_im::ObservableVector;
|
||||
use indexmap::IndexMap;
|
||||
use matrix_sdk::room;
|
||||
use matrix_sdk::Room;
|
||||
use ruma::{
|
||||
events::receipt::{Receipt, ReceiptEventContent, ReceiptThread, ReceiptType},
|
||||
EventId, OwnedEventId, OwnedUserId, UserId,
|
||||
@@ -129,7 +129,7 @@ impl TimelineInnerState {
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
receipt_type: ReceiptType,
|
||||
room: &room::Common,
|
||||
room: &Room,
|
||||
) -> Option<(OwnedEventId, Receipt)> {
|
||||
if let Some(receipt) = self
|
||||
.users_read_receipts
|
||||
@@ -154,7 +154,7 @@ impl TimelineInnerState {
|
||||
pub(super) async fn latest_user_read_receipt(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
room: &room::Common,
|
||||
room: &Room,
|
||||
) -> Option<(OwnedEventId, Receipt)> {
|
||||
let public_read_receipt = self.user_receipt(user_id, ReceiptType::Read, room).await;
|
||||
let private_read_receipt = self.user_receipt(user_id, ReceiptType::ReadPrivate, room).await;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
use async_trait::async_trait;
|
||||
use indexmap::IndexMap;
|
||||
use matrix_sdk::room;
|
||||
use matrix_sdk::Room;
|
||||
#[cfg(feature = "e2e-encryption")]
|
||||
use matrix_sdk::{deserialized_responses::TimelineEvent, Result};
|
||||
use ruma::{
|
||||
@@ -52,7 +52,7 @@ pub trait RoomExt {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl RoomExt for room::Common {
|
||||
impl RoomExt for Room {
|
||||
async fn timeline(&self) -> Timeline {
|
||||
self.timeline_builder().build().await
|
||||
}
|
||||
@@ -71,7 +71,7 @@ pub(super) trait RoomDataProvider: Clone + Send + Sync + 'static {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl RoomDataProvider for room::Common {
|
||||
impl RoomDataProvider for Room {
|
||||
fn own_user_id(&self) -> &UserId {
|
||||
(**self).own_user_id()
|
||||
}
|
||||
@@ -137,7 +137,7 @@ pub(super) trait Decryptor: Clone + Send + Sync + 'static {
|
||||
|
||||
#[cfg(feature = "e2e-encryption")]
|
||||
#[async_trait]
|
||||
impl Decryptor for room::Common {
|
||||
impl Decryptor for Room {
|
||||
async fn decrypt_event_impl(&self, raw: &Raw<AnySyncTimelineEvent>) -> Result<TimelineEvent> {
|
||||
self.decrypt_event(raw.cast_ref()).await
|
||||
}
|
||||
|
||||
@@ -84,9 +84,9 @@ use crate::{
|
||||
http_client::HttpClient,
|
||||
matrix_auth::MatrixAuth,
|
||||
notification_settings::NotificationSettings,
|
||||
room,
|
||||
sync::{RoomUpdate, SyncResponse},
|
||||
Account, AuthApi, AuthSession, Error, Media, RefreshTokenError, Result, TransmissionProgress,
|
||||
Account, AuthApi, AuthSession, Error, Media, RefreshTokenError, Result, Room,
|
||||
TransmissionProgress,
|
||||
};
|
||||
|
||||
mod builder;
|
||||
@@ -104,10 +104,9 @@ type NotificationHandlerFut = Pin<Box<dyn Future<Output = ()>>>;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
type NotificationHandlerFn =
|
||||
Box<dyn Fn(Notification, room::Common, Client) -> NotificationHandlerFut + Send + Sync>;
|
||||
Box<dyn Fn(Notification, Room, Client) -> NotificationHandlerFut + Send + Sync>;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
type NotificationHandlerFn =
|
||||
Box<dyn Fn(Notification, room::Common, Client) -> NotificationHandlerFut>;
|
||||
type NotificationHandlerFn = Box<dyn Fn(Notification, Room, Client) -> NotificationHandlerFut>;
|
||||
|
||||
/// Enum controlling if a loop running callbacks should continue or abort.
|
||||
///
|
||||
@@ -477,8 +476,8 @@ impl Client {
|
||||
/// the event handler being skipped and an error being logged. The following
|
||||
/// context argument types are only available for a subset of event types:
|
||||
///
|
||||
/// * [`room::Common`] is only available for room-specific events, i.e. not
|
||||
/// for events like global account data events or presence events.
|
||||
/// * [`Room`] is only available for room-specific events, i.e. not for
|
||||
/// events like global account data events or presence events.
|
||||
///
|
||||
/// You can provide custom context via
|
||||
/// [`add_event_handler_context`](Client::add_event_handler_context) and
|
||||
@@ -495,7 +494,6 @@ impl Client {
|
||||
/// use matrix_sdk::{
|
||||
/// deserialized_responses::EncryptionInfo,
|
||||
/// event_handler::Ctx,
|
||||
/// room::Common,
|
||||
/// ruma::{
|
||||
/// events::{
|
||||
/// macros::EventContent,
|
||||
@@ -505,7 +503,7 @@ impl Client {
|
||||
/// push::Action,
|
||||
/// Int, MilliSecondsSinceUnixEpoch,
|
||||
/// },
|
||||
/// Client,
|
||||
/// Client, Room,
|
||||
/// };
|
||||
/// use serde::{Deserialize, Serialize};
|
||||
///
|
||||
@@ -518,12 +516,12 @@ impl Client {
|
||||
/// # .unwrap();
|
||||
/// #
|
||||
/// client.add_event_handler(
|
||||
/// |ev: SyncRoomMessageEvent, room: Common, client: Client| async move {
|
||||
/// |ev: SyncRoomMessageEvent, room: Room, client: Client| async move {
|
||||
/// // Common usage: Room event plus room and client.
|
||||
/// },
|
||||
/// );
|
||||
/// client.add_event_handler(
|
||||
/// |ev: SyncRoomMessageEvent, room: Common, encryption_info: Option<EncryptionInfo>| {
|
||||
/// |ev: SyncRoomMessageEvent, room: Room, encryption_info: Option<EncryptionInfo>| {
|
||||
/// async move {
|
||||
/// // An `Option<EncryptionInfo>` parameter lets you distinguish between
|
||||
/// // unencrypted events and events that were decrypted by the SDK.
|
||||
@@ -531,7 +529,7 @@ impl Client {
|
||||
/// },
|
||||
/// );
|
||||
/// client.add_event_handler(
|
||||
/// |ev: SyncRoomMessageEvent, room: Common, push_actions: Vec<Action>| {
|
||||
/// |ev: SyncRoomMessageEvent, room: Room, push_actions: Vec<Action>| {
|
||||
/// async move {
|
||||
/// // A `Vec<Action>` parameter allows you to know which push actions
|
||||
/// // are applicable for an event. For example, an event with
|
||||
@@ -570,7 +568,7 @@ impl Client {
|
||||
/// expires_at: MilliSecondsSinceUnixEpoch,
|
||||
/// }
|
||||
///
|
||||
/// client.add_event_handler(|ev: SyncTokenEvent, room: Common| async move {
|
||||
/// client.add_event_handler(|ev: SyncTokenEvent, room: Room| async move {
|
||||
/// todo!("Display the token");
|
||||
/// });
|
||||
///
|
||||
@@ -699,8 +697,8 @@ impl Client {
|
||||
///
|
||||
/// ```
|
||||
/// use matrix_sdk::{
|
||||
/// event_handler::Ctx, room::Common,
|
||||
/// ruma::events::room::message::SyncRoomMessageEvent,
|
||||
/// event_handler::Ctx, ruma::events::room::message::SyncRoomMessageEvent,
|
||||
/// Room,
|
||||
/// };
|
||||
/// # #[derive(Clone)]
|
||||
/// # struct SomeType;
|
||||
@@ -719,7 +717,7 @@ impl Client {
|
||||
///
|
||||
/// client.add_event_handler_context(my_gui_handle.clone());
|
||||
/// client.add_event_handler(
|
||||
/// |ev: SyncRoomMessageEvent, room: Common, gui_handle: Ctx<SomeType>| {
|
||||
/// |ev: SyncRoomMessageEvent, room: Room, gui_handle: Ctx<SomeType>| {
|
||||
/// async move {
|
||||
/// // gui_handle.send(DisplayMessage { message: ev });
|
||||
/// }
|
||||
@@ -737,14 +735,11 @@ impl Client {
|
||||
/// Register a handler for a notification.
|
||||
///
|
||||
/// Similar to [`Client::add_event_handler`], but only allows functions
|
||||
/// or closures with exactly the three arguments [`Notification`],
|
||||
/// [`room::Common`], [`Client`] for now.
|
||||
/// or closures with exactly the three arguments [`Notification`], [`Room`],
|
||||
/// [`Client`] for now.
|
||||
pub async fn register_notification_handler<H, Fut>(&self, handler: H) -> &Self
|
||||
where
|
||||
H: Fn(Notification, room::Common, Client) -> Fut
|
||||
+ SendOutsideWasm
|
||||
+ SyncOutsideWasm
|
||||
+ 'static,
|
||||
H: Fn(Notification, Room, Client) -> Fut + SendOutsideWasm + SyncOutsideWasm + 'static,
|
||||
Fut: Future<Output = ()> + SendOutsideWasm + 'static,
|
||||
{
|
||||
self.inner.notification_handlers.write().await.push(Box::new(
|
||||
@@ -778,47 +773,47 @@ impl Client {
|
||||
/// Get all the rooms the client knows about.
|
||||
///
|
||||
/// This will return the list of joined, invited, and left rooms.
|
||||
pub fn rooms(&self) -> Vec<room::Common> {
|
||||
pub fn rooms(&self) -> Vec<Room> {
|
||||
self.base_client()
|
||||
.get_rooms()
|
||||
.into_iter()
|
||||
.map(|room| room::Common::new(self.clone(), room))
|
||||
.map(|room| Room::new(self.clone(), room))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Get all the rooms the client knows about, filtered by room state.
|
||||
pub fn rooms_filtered(&self, filter: RoomStateFilter) -> Vec<room::Common> {
|
||||
pub fn rooms_filtered(&self, filter: RoomStateFilter) -> Vec<Room> {
|
||||
self.base_client()
|
||||
.get_rooms_filtered(filter)
|
||||
.into_iter()
|
||||
.map(|room| room::Common::new(self.clone(), room))
|
||||
.map(|room| Room::new(self.clone(), room))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Returns the joined rooms this client knows about.
|
||||
pub fn joined_rooms(&self) -> Vec<room::Common> {
|
||||
pub fn joined_rooms(&self) -> Vec<Room> {
|
||||
self.base_client()
|
||||
.get_rooms_filtered(RoomStateFilter::JOINED)
|
||||
.into_iter()
|
||||
.map(|room| room::Common::new(self.clone(), room))
|
||||
.map(|room| Room::new(self.clone(), room))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Returns the invited rooms this client knows about.
|
||||
pub fn invited_rooms(&self) -> Vec<room::Common> {
|
||||
pub fn invited_rooms(&self) -> Vec<Room> {
|
||||
self.base_client()
|
||||
.get_rooms_filtered(RoomStateFilter::INVITED)
|
||||
.into_iter()
|
||||
.map(|room| room::Common::new(self.clone(), room))
|
||||
.map(|room| Room::new(self.clone(), room))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Returns the left rooms this client knows about.
|
||||
pub fn left_rooms(&self) -> Vec<room::Common> {
|
||||
pub fn left_rooms(&self) -> Vec<Room> {
|
||||
self.base_client()
|
||||
.get_rooms_filtered(RoomStateFilter::LEFT)
|
||||
.into_iter()
|
||||
.map(|room| room::Common::new(self.clone(), room))
|
||||
.map(|room| Room::new(self.clone(), room))
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -827,8 +822,8 @@ impl Client {
|
||||
/// # Arguments
|
||||
///
|
||||
/// `room_id` - The unique id of the room that should be fetched.
|
||||
pub fn get_room(&self, room_id: &RoomId) -> Option<room::Common> {
|
||||
self.base_client().get_room(room_id).map(|room| room::Common::new(self.clone(), room))
|
||||
pub fn get_room(&self, room_id: &RoomId) -> Option<Room> {
|
||||
self.base_client().get_room(room_id).map(|room| Room::new(self.clone(), room))
|
||||
}
|
||||
|
||||
/// Resolve a room alias to a room id and a list of servers which know
|
||||
@@ -974,11 +969,11 @@ impl Client {
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `room_id` - The `RoomId` of the room to be joined.
|
||||
pub async fn join_room_by_id(&self, room_id: &RoomId) -> Result<room::Common> {
|
||||
pub async fn join_room_by_id(&self, room_id: &RoomId) -> Result<Room> {
|
||||
let request = join_room_by_id::v3::Request::new(room_id.to_owned());
|
||||
let response = self.send(request, None).await?;
|
||||
let base_room = self.base_client().room_joined(&response.room_id).await?;
|
||||
Ok(room::Common::new(self.clone(), base_room))
|
||||
Ok(Room::new(self.clone(), base_room))
|
||||
}
|
||||
|
||||
/// Join a room by `RoomId`.
|
||||
@@ -994,13 +989,13 @@ impl Client {
|
||||
&self,
|
||||
alias: &RoomOrAliasId,
|
||||
server_names: &[OwnedServerName],
|
||||
) -> Result<room::Common> {
|
||||
) -> Result<Room> {
|
||||
let request = assign!(join_room_by_id_or_alias::v3::Request::new(alias.to_owned()), {
|
||||
server_name: server_names.to_owned(),
|
||||
});
|
||||
let response = self.send(request, None).await?;
|
||||
let base_room = self.base_client().room_joined(&response.room_id).await?;
|
||||
Ok(room::Common::new(self.clone(), base_room))
|
||||
Ok(Room::new(self.clone(), base_room))
|
||||
}
|
||||
|
||||
/// Search the homeserver's directory of public rooms.
|
||||
@@ -1079,14 +1074,14 @@ impl Client {
|
||||
/// assert!(client.create_room(request).await.is_ok());
|
||||
/// # };
|
||||
/// ```
|
||||
pub async fn create_room(&self, request: create_room::v3::Request) -> Result<room::Common> {
|
||||
pub async fn create_room(&self, request: create_room::v3::Request) -> Result<Room> {
|
||||
let invite = request.invite.clone();
|
||||
let is_direct_room = request.is_direct;
|
||||
let response = self.send(request, None).await?;
|
||||
|
||||
let base_room = self.base_client().get_or_create_room(&response.room_id, RoomState::Joined);
|
||||
|
||||
let joined_room = room::Common::new(self.clone(), base_room);
|
||||
let joined_room = Room::new(self.clone(), base_room);
|
||||
|
||||
if is_direct_room && !invite.is_empty() {
|
||||
if let Err(error) =
|
||||
@@ -1105,7 +1100,7 @@ impl Client {
|
||||
/// Convenience shorthand for [`create_room`][Self::create_room] with the
|
||||
/// given user being invited, the room marked `is_direct` and both the
|
||||
/// creator and invitee getting the default maximum power level.
|
||||
pub async fn create_dm(&self, user_id: &UserId) -> Result<room::Common> {
|
||||
pub async fn create_dm(&self, user_id: &UserId) -> Result<Room> {
|
||||
self.create_room(assign!(create_room::v3::Request::new(), {
|
||||
invite: vec![user_id.to_owned()],
|
||||
is_direct: true,
|
||||
|
||||
@@ -224,7 +224,7 @@ is **not** supported using the default store.
|
||||
[Megolm]: https://gitlab.matrix.org/matrix-org/olm/blob/master/docs/megolm.md
|
||||
[`UserIdentity`]: #struct.verification.UserIdentity
|
||||
[filtered]: crate::config::SyncSettings::filter
|
||||
[enabled]: crate::room::Common::enable_encryption
|
||||
[enabled]: crate::Room::enable_encryption
|
||||
[Restoring a Client]: #restoring-a-client
|
||||
[spec]: https://spec.matrix.org/unstable/client-server-api/#relationship-between-access-tokens-and-devices
|
||||
[device keys]: https://spec.matrix.org/unstable/client-server-api/#device-keys
|
||||
|
||||
@@ -31,7 +31,7 @@ use ruma::{
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use super::{ManualVerifyError, RequestVerificationError};
|
||||
use crate::{encryption::verification::VerificationRequest, room::Common, Client};
|
||||
use crate::{encryption::verification::VerificationRequest, Client, Room};
|
||||
|
||||
/// A struct representing a E2EE capable identity of a user.
|
||||
///
|
||||
@@ -78,7 +78,7 @@ impl UserIdentity {
|
||||
Self { inner: identity.into() }
|
||||
}
|
||||
|
||||
pub(crate) fn new(client: Client, identity: InnerUserIdentity, room: Option<Common>) -> Self {
|
||||
pub(crate) fn new(client: Client, identity: InnerUserIdentity, room: Option<Room>) -> Self {
|
||||
let identity = OtherUserIdentity {
|
||||
inner: identity,
|
||||
client,
|
||||
@@ -425,7 +425,7 @@ struct OwnUserIdentity {
|
||||
struct OtherUserIdentity {
|
||||
pub(crate) inner: InnerUserIdentity,
|
||||
pub(crate) client: Client,
|
||||
pub(crate) direct_message_room: Arc<RwLock<Option<Common>>>,
|
||||
pub(crate) direct_message_room: Arc<RwLock<Option<Room>>>,
|
||||
}
|
||||
|
||||
impl OwnUserIdentity {
|
||||
|
||||
@@ -64,7 +64,7 @@ use crate::{
|
||||
verification::{SasVerification, Verification, VerificationRequest},
|
||||
},
|
||||
error::HttpResult,
|
||||
room, Client, Error, Result, TransmissionProgress,
|
||||
Client, Error, Result, Room, TransmissionProgress,
|
||||
};
|
||||
|
||||
mod futures;
|
||||
@@ -358,7 +358,7 @@ impl Client {
|
||||
}
|
||||
|
||||
/// Get the existing DM room with the given user, if any.
|
||||
pub fn get_dm_room(&self, user_id: &UserId) -> Option<room::Common> {
|
||||
pub fn get_dm_room(&self, user_id: &UserId) -> Option<Room> {
|
||||
let rooms = self.joined_rooms();
|
||||
|
||||
// Find the room we share with the `user_id` and only with `user_id`
|
||||
|
||||
@@ -20,7 +20,7 @@ use ruma::push::Action;
|
||||
use serde_json::value::RawValue as RawJsonValue;
|
||||
|
||||
use super::{EventHandlerData, EventHandlerHandle};
|
||||
use crate::{room, Client};
|
||||
use crate::{Client, Room};
|
||||
|
||||
/// Context for an event handler.
|
||||
///
|
||||
@@ -49,7 +49,7 @@ impl EventHandlerContext for EventHandlerHandle {
|
||||
/// Trying to use it in the event handler for another event, for example a
|
||||
/// global account data or presence event, will result in the event handler
|
||||
/// being skipped and an error getting logged.
|
||||
impl EventHandlerContext for room::Common {
|
||||
impl EventHandlerContext for Room {
|
||||
fn from_data(data: &EventHandlerData<'_>) -> Option<Self> {
|
||||
data.room.clone()
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ use serde_json::value::RawValue as RawJsonValue;
|
||||
use tracing::{debug, error, field::debug, instrument, warn};
|
||||
|
||||
use self::maps::EventHandlerMaps;
|
||||
use crate::{room, Client};
|
||||
use crate::{Client, Room};
|
||||
|
||||
mod context;
|
||||
mod maps;
|
||||
@@ -231,7 +231,7 @@ where
|
||||
#[derive(Debug)]
|
||||
pub struct EventHandlerData<'a> {
|
||||
client: Client,
|
||||
room: Option<room::Common>,
|
||||
room: Option<Room>,
|
||||
raw: &'a RawJsonValue,
|
||||
encryption_info: Option<&'a EncryptionInfo>,
|
||||
push_actions: &'a [Action],
|
||||
@@ -328,7 +328,7 @@ impl Client {
|
||||
pub(crate) async fn handle_sync_events<T>(
|
||||
&self,
|
||||
kind: HandlerKind,
|
||||
room: Option<&room::Common>,
|
||||
room: Option<&Room>,
|
||||
events: &[Raw<T>],
|
||||
) -> serde_json::Result<()> {
|
||||
#[derive(Deserialize)]
|
||||
@@ -347,7 +347,7 @@ impl Client {
|
||||
|
||||
pub(crate) async fn handle_sync_state_events(
|
||||
&self,
|
||||
room: Option<&room::Common>,
|
||||
room: Option<&Room>,
|
||||
state_events: &[Raw<AnySyncStateEvent>],
|
||||
) -> serde_json::Result<()> {
|
||||
#[derive(Deserialize)]
|
||||
@@ -375,7 +375,7 @@ impl Client {
|
||||
|
||||
pub(crate) async fn handle_sync_timeline_events(
|
||||
&self,
|
||||
room: Option<&room::Common>,
|
||||
room: Option<&Room>,
|
||||
timeline_events: &[SyncTimelineEvent],
|
||||
) -> serde_json::Result<()> {
|
||||
#[derive(Deserialize)]
|
||||
@@ -441,7 +441,7 @@ impl Client {
|
||||
#[instrument(skip_all, fields(?event_kind, ?event_type, room_id))]
|
||||
async fn call_event_handlers(
|
||||
&self,
|
||||
room: Option<&room::Common>,
|
||||
room: Option<&Room>,
|
||||
raw: &RawJsonValue,
|
||||
event_kind: HandlerKind,
|
||||
event_type: &str,
|
||||
@@ -571,9 +571,8 @@ mod tests {
|
||||
|
||||
use crate::{
|
||||
event_handler::Ctx,
|
||||
room,
|
||||
test_utils::{logged_in_client, no_retry_test_client},
|
||||
Client,
|
||||
Client, Room,
|
||||
};
|
||||
|
||||
#[async_test]
|
||||
@@ -587,7 +586,7 @@ mod tests {
|
||||
|
||||
client.add_event_handler({
|
||||
let member_count = member_count.clone();
|
||||
move |_ev: OriginalSyncRoomMemberEvent, _room: room::Common| {
|
||||
move |_ev: OriginalSyncRoomMemberEvent, _room: Room| {
|
||||
member_count.fetch_add(1, SeqCst);
|
||||
future::ready(())
|
||||
}
|
||||
@@ -601,7 +600,7 @@ mod tests {
|
||||
});
|
||||
client.add_event_handler({
|
||||
let power_levels_count = power_levels_count.clone();
|
||||
move |_ev: OriginalSyncRoomPowerLevelsEvent, _client: Client, _room: room::Common| {
|
||||
move |_ev: OriginalSyncRoomPowerLevelsEvent, _client: Client, _room: Room| {
|
||||
power_levels_count.fetch_add(1, SeqCst);
|
||||
future::ready(())
|
||||
}
|
||||
@@ -683,14 +682,14 @@ mod tests {
|
||||
// Room event handlers for member events in both rooms
|
||||
client.add_room_event_handler(room_id_a, {
|
||||
let member_count = member_count.clone();
|
||||
move |_ev: OriginalSyncRoomMemberEvent, _room: room::Common| {
|
||||
move |_ev: OriginalSyncRoomMemberEvent, _room: Room| {
|
||||
member_count.fetch_add(1, SeqCst);
|
||||
future::ready(())
|
||||
}
|
||||
});
|
||||
client.add_room_event_handler(room_id_b, {
|
||||
let member_count = member_count.clone();
|
||||
move |_ev: OriginalSyncRoomMemberEvent, _room: room::Common| {
|
||||
move |_ev: OriginalSyncRoomMemberEvent, _room: Room| {
|
||||
member_count.fetch_add(1, SeqCst);
|
||||
future::ready(())
|
||||
}
|
||||
@@ -699,7 +698,7 @@ mod tests {
|
||||
// Power levels event handlers for member events in room A
|
||||
client.add_room_event_handler(room_id_a, {
|
||||
let power_levels_count = power_levels_count.clone();
|
||||
move |_ev: OriginalSyncRoomPowerLevelsEvent, _client: Client, _room: room::Common| {
|
||||
move |_ev: OriginalSyncRoomPowerLevelsEvent, _client: Client, _room: Room| {
|
||||
power_levels_count.fetch_add(1, SeqCst);
|
||||
future::ready(())
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ pub use http_client::TransmissionProgress;
|
||||
#[cfg(all(feature = "e2e-encryption", feature = "sqlite"))]
|
||||
pub use matrix_sdk_sqlite::SqliteCryptoStore;
|
||||
pub use media::Media;
|
||||
pub use room::Room;
|
||||
pub use ruma::{IdParseError, OwnedServerName, ServerName};
|
||||
#[cfg(feature = "experimental-sliding-sync")]
|
||||
pub use sliding_sync::{
|
||||
|
||||
@@ -10,7 +10,7 @@ use mime::Mime;
|
||||
use ruma::api::client::message::send_message_event;
|
||||
use tracing::{Instrument, Span};
|
||||
|
||||
use super::Common;
|
||||
use super::Room;
|
||||
use crate::{attachment::AttachmentConfig, Result, TransmissionProgress};
|
||||
#[cfg(feature = "image-proc")]
|
||||
use crate::{
|
||||
@@ -18,10 +18,10 @@ use crate::{
|
||||
error::ImageError,
|
||||
};
|
||||
|
||||
/// Future returned by [`Common::send_attachment`].
|
||||
/// Future returned by [`Room::send_attachment`].
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct SendAttachment<'a> {
|
||||
room: &'a Common,
|
||||
room: &'a Room,
|
||||
body: &'a str,
|
||||
content_type: &'a Mime,
|
||||
data: Vec<u8>,
|
||||
@@ -32,7 +32,7 @@ pub struct SendAttachment<'a> {
|
||||
|
||||
impl<'a> SendAttachment<'a> {
|
||||
pub(crate) fn new(
|
||||
room: &'a Common,
|
||||
room: &'a Room,
|
||||
body: &'a str,
|
||||
content_type: &'a Mime,
|
||||
data: Vec<u8>,
|
||||
|
||||
@@ -26,7 +26,7 @@ use ruma::{
|
||||
uint, RoomId, UInt,
|
||||
};
|
||||
|
||||
/// Options for [`messages`][super::Common::messages].
|
||||
/// Options for [`messages`][super::Room::messages].
|
||||
///
|
||||
/// See that method and
|
||||
/// <https://spec.matrix.org/v1.3/client-server-api/#get_matrixclientv3roomsroomidmessages>
|
||||
|
||||
@@ -88,12 +88,12 @@ pub use self::{
|
||||
/// A struct containing methods that are common for Joined, Invited and Left
|
||||
/// Rooms
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Common {
|
||||
pub struct Room {
|
||||
inner: BaseRoom,
|
||||
pub(crate) client: Client,
|
||||
}
|
||||
|
||||
impl Deref for Common {
|
||||
impl Deref for Room {
|
||||
type Target = BaseRoom;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
@@ -104,8 +104,8 @@ impl Deref for Common {
|
||||
const TYPING_NOTICE_TIMEOUT: Duration = Duration::from_secs(4);
|
||||
const TYPING_NOTICE_RESEND_TIMEOUT: Duration = Duration::from_secs(3);
|
||||
|
||||
impl Common {
|
||||
/// Create a new `room::Common`
|
||||
impl Room {
|
||||
/// Create a new `Room`
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `client` - The client used to make requests.
|
||||
@@ -590,7 +590,7 @@ impl Common {
|
||||
///
|
||||
/// ```no_run
|
||||
/// # async {
|
||||
/// # let room: matrix_sdk::room::Common = todo!();
|
||||
/// # let room: matrix_sdk::Room = todo!();
|
||||
/// use matrix_sdk::ruma::{
|
||||
/// events::room::member::RoomMemberEventContent, serde::Raw,
|
||||
/// };
|
||||
@@ -629,7 +629,7 @@ impl Common {
|
||||
///
|
||||
/// ```no_run
|
||||
/// # async {
|
||||
/// # let room: matrix_sdk::room::Common = todo!();
|
||||
/// # let room: matrix_sdk::Room = todo!();
|
||||
/// # let user_ids: &[matrix_sdk::ruma::OwnedUserId] = &[];
|
||||
/// use matrix_sdk::ruma::events::room::member::RoomMemberEventContent;
|
||||
///
|
||||
@@ -676,7 +676,7 @@ impl Common {
|
||||
///
|
||||
/// ```no_run
|
||||
/// # async {
|
||||
/// # let room: matrix_sdk::room::Common = todo!();
|
||||
/// # let room: matrix_sdk::Room = todo!();
|
||||
/// use matrix_sdk::ruma::events::room::power_levels::RoomPowerLevelsEventContent;
|
||||
///
|
||||
/// let power_levels = room
|
||||
@@ -701,7 +701,7 @@ impl Common {
|
||||
///
|
||||
/// ```no_run
|
||||
/// # async {
|
||||
/// # let room: matrix_sdk::room::Common = todo!();
|
||||
/// # let room: matrix_sdk::Room = todo!();
|
||||
/// use matrix_sdk::ruma::{
|
||||
/// events::room::member::RoomMemberEventContent, serde::Raw, user_id,
|
||||
/// };
|
||||
@@ -745,7 +745,7 @@ impl Common {
|
||||
///
|
||||
/// ```no_run
|
||||
/// # async {
|
||||
/// # let room: matrix_sdk::room::Common = todo!();
|
||||
/// # let room: matrix_sdk::Room = todo!();
|
||||
/// use matrix_sdk::ruma::events::fully_read::FullyReadEventContent;
|
||||
///
|
||||
/// match room.account_data_static::<FullyReadEventContent>().await? {
|
||||
@@ -1721,7 +1721,7 @@ impl Common {
|
||||
/// ```no_run
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # async {
|
||||
/// # let joined_room: matrix_sdk::room::Common = todo!();
|
||||
/// # let joined_room: matrix_sdk::Room = todo!();
|
||||
/// use matrix_sdk::ruma::{
|
||||
/// events::{
|
||||
/// macros::EventContent, room::encryption::RoomEncryptionEventContent,
|
||||
@@ -1772,7 +1772,7 @@ impl Common {
|
||||
/// ```no_run
|
||||
/// # use serde::{Deserialize, Serialize};
|
||||
/// # async {
|
||||
/// # let joined_room: matrix_sdk::room::Common = todo!();
|
||||
/// # let joined_room: matrix_sdk::Room = todo!();
|
||||
/// use matrix_sdk::ruma::{
|
||||
/// events::{
|
||||
/// macros::EventContent,
|
||||
|
||||
@@ -240,7 +240,7 @@ impl SlidingSyncRoom {
|
||||
|
||||
#[derive(Debug)]
|
||||
struct SlidingSyncRoomInner {
|
||||
/// The client, used to fetch [`room::Common`][crate::room::Common].
|
||||
/// The client, used to fetch [`Room`][crate::Room].
|
||||
client: Client,
|
||||
|
||||
/// The room ID.
|
||||
|
||||
@@ -39,7 +39,7 @@ use ruma::{
|
||||
};
|
||||
use tracing::{debug, error, warn};
|
||||
|
||||
use crate::{event_handler::HandlerKind, room, Client, Result};
|
||||
use crate::{event_handler::HandlerKind, Client, Result, Room};
|
||||
|
||||
/// The processed response of a `/sync` request.
|
||||
#[derive(Clone, Default)]
|
||||
@@ -116,21 +116,21 @@ pub enum RoomUpdate {
|
||||
/// Updates to a room the user is no longer in.
|
||||
Left {
|
||||
/// Room object with general information on the room.
|
||||
room: room::Common,
|
||||
room: Room,
|
||||
/// Updates to the room.
|
||||
updates: LeftRoom,
|
||||
},
|
||||
/// Updates to a room the user is currently in.
|
||||
Joined {
|
||||
/// Room object with general information on the room.
|
||||
room: room::Common,
|
||||
room: Room,
|
||||
/// Updates to the room.
|
||||
updates: JoinedRoom,
|
||||
},
|
||||
/// Updates to a room the user is invited to.
|
||||
Invited {
|
||||
/// Room object with general information on the room.
|
||||
room: room::Common,
|
||||
room: Room,
|
||||
/// Updates to the room.
|
||||
updates: InvitedRoom,
|
||||
},
|
||||
|
||||
@@ -3,11 +3,11 @@ use std::env;
|
||||
use matrix_sdk_appservice::{
|
||||
matrix_sdk::{
|
||||
event_handler::Ctx,
|
||||
room,
|
||||
ruma::{
|
||||
events::room::member::{MembershipState, OriginalSyncRoomMemberEvent},
|
||||
UserId,
|
||||
},
|
||||
Room,
|
||||
},
|
||||
ruma::api::client::error::ErrorKind,
|
||||
AppService, AppServiceBuilder, AppServiceRegistration, Result,
|
||||
@@ -16,7 +16,7 @@ use tracing::trace;
|
||||
|
||||
pub async fn handle_room_member(
|
||||
appservice: AppService,
|
||||
room: room::Common,
|
||||
room: Room,
|
||||
event: OriginalSyncRoomMemberEvent,
|
||||
) -> Result<()> {
|
||||
if !appservice.user_id_is_in_namespace(&event.state_key) {
|
||||
@@ -68,9 +68,7 @@ pub async fn main() -> anyhow::Result<()> {
|
||||
|
||||
user.add_event_handler_context(appservice.clone());
|
||||
user.add_event_handler(
|
||||
move |event: OriginalSyncRoomMemberEvent,
|
||||
room: room::Common,
|
||||
Ctx(appservice): Ctx<AppService>| {
|
||||
move |event: OriginalSyncRoomMemberEvent, room: Room, Ctx(appservice): Ctx<AppService>| {
|
||||
handle_room_member(appservice, room, event)
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{env, process::exit};
|
||||
|
||||
use matrix_sdk::{
|
||||
config::SyncSettings, room, ruma::events::room::member::StrippedRoomMemberEvent, Client,
|
||||
config::SyncSettings, ruma::events::room::member::StrippedRoomMemberEvent, Client, Room,
|
||||
RoomState,
|
||||
};
|
||||
use tokio::time::{sleep, Duration};
|
||||
@@ -9,7 +9,7 @@ use tokio::time::{sleep, Duration};
|
||||
async fn on_stripped_state_member(
|
||||
room_member: StrippedRoomMemberEvent,
|
||||
client: Client,
|
||||
room: room::Common,
|
||||
room: Room,
|
||||
) {
|
||||
if room_member.state_key != client.user_id().unwrap() {
|
||||
return;
|
||||
|
||||
@@ -2,14 +2,13 @@ use std::{env, process::exit};
|
||||
|
||||
use matrix_sdk::{
|
||||
config::SyncSettings,
|
||||
room,
|
||||
ruma::events::room::message::{
|
||||
MessageType, OriginalSyncRoomMessageEvent, RoomMessageEventContent,
|
||||
},
|
||||
Client, RoomState,
|
||||
Client, Room, RoomState,
|
||||
};
|
||||
|
||||
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: room::Common) {
|
||||
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) {
|
||||
if room.state() != RoomState::Joined {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ use std::{env, process::exit};
|
||||
|
||||
use matrix_sdk::{
|
||||
config::SyncSettings,
|
||||
room,
|
||||
ruma::{
|
||||
events::{
|
||||
macros::EventContent,
|
||||
@@ -24,7 +23,7 @@ use matrix_sdk::{
|
||||
},
|
||||
OwnedEventId,
|
||||
},
|
||||
Client, RoomState,
|
||||
Client, Room, RoomState,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::time::{sleep, Duration};
|
||||
@@ -50,7 +49,7 @@ pub struct AckEventContent {
|
||||
// use that for `on_ping_event`.
|
||||
|
||||
// we want to start the ping-ack-flow on "!ping" messages.
|
||||
async fn on_regular_room_message(event: OriginalSyncRoomMessageEvent, room: room::Common) {
|
||||
async fn on_regular_room_message(event: OriginalSyncRoomMessageEvent, room: Room) {
|
||||
if room.state() != RoomState::Joined {
|
||||
return;
|
||||
}
|
||||
@@ -66,7 +65,7 @@ async fn on_regular_room_message(event: OriginalSyncRoomMessageEvent, room: room
|
||||
}
|
||||
|
||||
// call this on any PingEvent we receive
|
||||
async fn on_ping_event(event: SyncPingEvent, room: room::Common) {
|
||||
async fn on_ping_event(event: SyncPingEvent, room: Room) {
|
||||
if room.state() != RoomState::Joined {
|
||||
return;
|
||||
}
|
||||
@@ -124,7 +123,7 @@ async fn login_and_sync(
|
||||
async fn on_stripped_state_member(
|
||||
room_member: StrippedRoomMemberEvent,
|
||||
client: Client,
|
||||
room: room::Common,
|
||||
room: Room,
|
||||
) {
|
||||
if room_member.state_key != client.user_id().unwrap() {
|
||||
// the invite we've seen isn't for us, but for someone else. ignore
|
||||
|
||||
@@ -14,12 +14,11 @@ use std::{env, process::exit};
|
||||
|
||||
use matrix_sdk::{
|
||||
config::SyncSettings,
|
||||
room,
|
||||
ruma::events::room::{
|
||||
member::StrippedRoomMemberEvent,
|
||||
message::{MessageType, OriginalSyncRoomMessageEvent, RoomMessageEventContent},
|
||||
},
|
||||
Client, RoomState,
|
||||
Client, Room, RoomState,
|
||||
};
|
||||
use tokio::time::{sleep, Duration};
|
||||
|
||||
@@ -108,7 +107,7 @@ async fn login_and_sync(
|
||||
async fn on_stripped_state_member(
|
||||
room_member: StrippedRoomMemberEvent,
|
||||
client: Client,
|
||||
room: room::Common,
|
||||
room: Room,
|
||||
) {
|
||||
if room_member.state_key != client.user_id().unwrap() {
|
||||
// the invite we've seen isn't for us, but for someone else. ignore
|
||||
@@ -146,7 +145,7 @@ async fn on_stripped_state_member(
|
||||
// handler lies only in their input parameters. However, that is enough for the
|
||||
// rust-sdk to figure out which one to call one and only do so, when
|
||||
// the parameters are available.
|
||||
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: room::Common) {
|
||||
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) {
|
||||
// First, we need to unpack the message: We only want messages from rooms we are
|
||||
// still in and that are regular text messages - ignoring everything else.
|
||||
if room.state() != RoomState::Joined {
|
||||
|
||||
@@ -4,13 +4,12 @@ use matrix_sdk::{
|
||||
self,
|
||||
attachment::AttachmentConfig,
|
||||
config::SyncSettings,
|
||||
room,
|
||||
ruma::events::room::message::{MessageType, OriginalSyncRoomMessageEvent},
|
||||
Client, RoomState,
|
||||
Client, Room, RoomState,
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: room::Common, image: Vec<u8>) {
|
||||
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room, image: Vec<u8>) {
|
||||
if room.state() != RoomState::Joined {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8,12 +8,11 @@ use anyhow::anyhow;
|
||||
use matrix_sdk::{
|
||||
self,
|
||||
config::SyncSettings,
|
||||
room,
|
||||
ruma::{
|
||||
api::client::session::get_login_types::v3::{IdentityProvider, LoginType},
|
||||
events::room::message::{MessageType, OriginalSyncRoomMessageEvent},
|
||||
},
|
||||
Client, RoomState,
|
||||
Client, Room, RoomState,
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
@@ -208,7 +207,7 @@ async fn login_with_sso(client: &Client, idp: Option<&IdentityProvider>) -> anyh
|
||||
}
|
||||
|
||||
/// Handle room messages by logging them.
|
||||
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: room::Common) {
|
||||
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) {
|
||||
// We only want to listen to joined rooms.
|
||||
if room.state() != RoomState::Joined {
|
||||
return;
|
||||
|
||||
@@ -5,12 +5,11 @@ use std::{
|
||||
|
||||
use matrix_sdk::{
|
||||
config::SyncSettings,
|
||||
room,
|
||||
ruma::{
|
||||
api::client::filter::FilterDefinition,
|
||||
events::room::message::{MessageType, OriginalSyncRoomMessageEvent},
|
||||
},
|
||||
AuthSession, Client, Error, LoopCtrl, RoomState,
|
||||
AuthSession, Client, Error, LoopCtrl, Room, RoomState,
|
||||
};
|
||||
use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -290,7 +289,7 @@ async fn persist_sync_token(session_file: &Path, sync_token: String) -> anyhow::
|
||||
}
|
||||
|
||||
/// Handle room messages.
|
||||
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: room::Common) {
|
||||
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) {
|
||||
// We only want to log text messages in joined rooms.
|
||||
if room.state() != RoomState::Joined {
|
||||
return;
|
||||
|
||||
@@ -4,12 +4,11 @@ use anyhow::Result;
|
||||
use assign::assign;
|
||||
use matrix_sdk::{
|
||||
event_handler::Ctx,
|
||||
room,
|
||||
ruma::{
|
||||
api::client::room::create_room::v3::Request as CreateRoomRequest,
|
||||
events::room::member::{MembershipState, StrippedRoomMemberEvent},
|
||||
},
|
||||
Client, RoomMemberships, RoomState, StateStoreExt,
|
||||
Client, Room, RoomMemberships, RoomState, StateStoreExt,
|
||||
};
|
||||
use tokio::sync::Notify;
|
||||
|
||||
@@ -120,7 +119,7 @@ async fn test_repeated_join_leave() -> Result<()> {
|
||||
|
||||
async fn signal_on_invite(
|
||||
event: StrippedRoomMemberEvent,
|
||||
room: room::Common,
|
||||
room: Room,
|
||||
client: Client,
|
||||
sender: Ctx<Arc<Notify>>,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user