matrix-sdk: Reexport matrix_sdk_base::Room as BaseRoom
parent
31dd031269
commit
5d66ff475f
|
@ -4,7 +4,7 @@ use tokio::time::{sleep, Duration};
|
||||||
use matrix_sdk::{
|
use matrix_sdk::{
|
||||||
self, async_trait,
|
self, async_trait,
|
||||||
events::{room::member::MemberEventContent, StrippedStateEvent},
|
events::{room::member::MemberEventContent, StrippedStateEvent},
|
||||||
room, Client, ClientConfig, EventHandler, Room, SyncSettings,
|
room, BaseRoom, Client, ClientConfig, EventHandler, SyncSettings,
|
||||||
};
|
};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ impl AutoJoinBot {
|
||||||
impl EventHandler for AutoJoinBot {
|
impl EventHandler for AutoJoinBot {
|
||||||
async fn on_stripped_state_member(
|
async fn on_stripped_state_member(
|
||||||
&self,
|
&self,
|
||||||
room: Room,
|
room: BaseRoom,
|
||||||
room_member: &StrippedStateEvent<MemberEventContent>,
|
room_member: &StrippedStateEvent<MemberEventContent>,
|
||||||
_: Option<MemberEventContent>,
|
_: Option<MemberEventContent>,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ use matrix_sdk::{
|
||||||
AnyMessageEventContent, SyncMessageEvent,
|
AnyMessageEventContent, SyncMessageEvent,
|
||||||
},
|
},
|
||||||
room::Joined,
|
room::Joined,
|
||||||
Client, ClientConfig, EventHandler, Room, SyncSettings,
|
BaseRoom, Client, ClientConfig, EventHandler, SyncSettings,
|
||||||
};
|
};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ impl CommandBot {
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl EventHandler for CommandBot {
|
impl EventHandler for CommandBot {
|
||||||
async fn on_room_message(&self, room: Room, event: &SyncMessageEvent<MessageEventContent>) {
|
async fn on_room_message(&self, room: BaseRoom, event: &SyncMessageEvent<MessageEventContent>) {
|
||||||
if let Some(room) = Joined::new(self.client.clone(), room) {
|
if let Some(room) = Joined::new(self.client.clone(), room) {
|
||||||
let msg_body = if let SyncMessageEvent {
|
let msg_body = if let SyncMessageEvent {
|
||||||
content:
|
content:
|
||||||
|
|
|
@ -15,7 +15,7 @@ use matrix_sdk::{
|
||||||
SyncMessageEvent,
|
SyncMessageEvent,
|
||||||
},
|
},
|
||||||
room::Joined,
|
room::Joined,
|
||||||
Client, EventHandler, Room, SyncSettings,
|
BaseRoom, Client, EventHandler, SyncSettings,
|
||||||
};
|
};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ impl ImageBot {
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl EventHandler for ImageBot {
|
impl EventHandler for ImageBot {
|
||||||
async fn on_room_message(&self, room: Room, event: &SyncMessageEvent<MessageEventContent>) {
|
async fn on_room_message(&self, room: BaseRoom, event: &SyncMessageEvent<MessageEventContent>) {
|
||||||
if let Some(room) = Joined::new(self.client.clone(), room) {
|
if let Some(room) = Joined::new(self.client.clone(), room) {
|
||||||
let msg_body = if let SyncMessageEvent {
|
let msg_body = if let SyncMessageEvent {
|
||||||
content:
|
content:
|
||||||
|
|
|
@ -7,14 +7,14 @@ use matrix_sdk::{
|
||||||
room::message::{MessageEventContent, MessageType, TextMessageEventContent},
|
room::message::{MessageEventContent, MessageType, TextMessageEventContent},
|
||||||
SyncMessageEvent,
|
SyncMessageEvent,
|
||||||
},
|
},
|
||||||
Client, EventHandler, Room, RoomType, SyncSettings,
|
BaseRoom, Client, EventHandler, RoomType, SyncSettings,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EventCallback;
|
struct EventCallback;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl EventHandler for EventCallback {
|
impl EventHandler for EventCallback {
|
||||||
async fn on_room_message(&self, room: Room, event: &SyncMessageEvent<MessageEventContent>) {
|
async fn on_room_message(&self, room: BaseRoom, event: &SyncMessageEvent<MessageEventContent>) {
|
||||||
if room.room_type() == RoomType::Joined {
|
if room.room_type() == RoomType::Joined {
|
||||||
if let SyncMessageEvent {
|
if let SyncMessageEvent {
|
||||||
content:
|
content:
|
||||||
|
|
|
@ -68,8 +68,8 @@ compile_error!("only one of 'native-tls' or 'rustls-tls' features can be enabled
|
||||||
#[cfg_attr(feature = "docs", doc(cfg(encryption)))]
|
#[cfg_attr(feature = "docs", doc(cfg(encryption)))]
|
||||||
pub use matrix_sdk_base::crypto::{EncryptionInfo, LocalTrust};
|
pub use matrix_sdk_base::crypto::{EncryptionInfo, LocalTrust};
|
||||||
pub use matrix_sdk_base::{
|
pub use matrix_sdk_base::{
|
||||||
CustomEvent, Error as BaseError, EventHandler, Room, RoomInfo, RoomMember, RoomType, Session,
|
CustomEvent, Error as BaseError, EventHandler, Room as BaseRoom, RoomInfo, RoomMember,
|
||||||
StateChanges, StoreError,
|
RoomType, Session, StateChanges, StoreError,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use matrix_sdk_common::*;
|
pub use matrix_sdk_common::*;
|
||||||
|
|
|
@ -4,17 +4,17 @@ use matrix_sdk_common::api::r0::{
|
||||||
};
|
};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use crate::{Client, Result, Room, RoomMember};
|
use crate::{BaseRoom, Client, Result, RoomMember};
|
||||||
|
|
||||||
/// A struct containing methodes that are common for Joined, Invited and Left Rooms
|
/// A struct containing methodes that are common for Joined, Invited and Left Rooms
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Common {
|
pub struct Common {
|
||||||
inner: Room,
|
inner: BaseRoom,
|
||||||
pub(crate) client: Client,
|
pub(crate) client: Client,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for Common {
|
impl Deref for Common {
|
||||||
type Target = Room;
|
type Target = BaseRoom;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.inner
|
&self.inner
|
||||||
|
@ -28,7 +28,7 @@ impl Common {
|
||||||
/// * `client` - The client used to make requests.
|
/// * `client` - The client used to make requests.
|
||||||
///
|
///
|
||||||
/// * `room` - The underlaying room.
|
/// * `room` - The underlaying room.
|
||||||
pub fn new(client: Client, room: Room) -> Self {
|
pub fn new(client: Client, room: BaseRoom) -> Self {
|
||||||
// TODO: Make this private
|
// TODO: Make this private
|
||||||
Self {
|
Self {
|
||||||
inner: room,
|
inner: room,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{room::Common, Client, Result, Room, RoomType};
|
use crate::{room::Common, BaseRoom, Client, Result, RoomType};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
/// A room in the invited state.
|
/// A room in the invited state.
|
||||||
|
@ -17,7 +17,7 @@ impl Invited {
|
||||||
/// * `client` - The client used to make requests.
|
/// * `client` - The client used to make requests.
|
||||||
///
|
///
|
||||||
/// * `room` - The underlaying room.
|
/// * `room` - The underlaying room.
|
||||||
pub fn new(client: Client, room: Room) -> Option<Self> {
|
pub fn new(client: Client, room: BaseRoom) -> Option<Self> {
|
||||||
// TODO: Make this private
|
// TODO: Make this private
|
||||||
if room.room_type() == RoomType::Invited {
|
if room.room_type() == RoomType::Invited {
|
||||||
Some(Self {
|
Some(Self {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{room::Common, Client, Result, Room, RoomType};
|
use crate::{room::Common, BaseRoom, Client, Result, RoomType};
|
||||||
use std::{io::Read, ops::Deref, sync::Arc};
|
use std::{io::Read, ops::Deref, sync::Arc};
|
||||||
|
|
||||||
use matrix_sdk_common::{
|
use matrix_sdk_common::{
|
||||||
|
@ -58,13 +58,13 @@ impl Deref for Joined {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Joined {
|
impl Joined {
|
||||||
/// Create a new `room::Joined` if the underlaying `Room` has type `RoomType::Joined`.
|
/// Create a new `room::Joined` if the underlaying `BaseRoom` has type `RoomType::Joined`.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
/// * `client` - The client used to make requests.
|
/// * `client` - The client used to make requests.
|
||||||
///
|
///
|
||||||
/// * `room` - The underlaying room.
|
/// * `room` - The underlaying room.
|
||||||
pub fn new(client: Client, room: Room) -> Option<Self> {
|
pub fn new(client: Client, room: BaseRoom) -> Option<Self> {
|
||||||
// TODO: Make this private
|
// TODO: Make this private
|
||||||
if room.room_type() == RoomType::Joined {
|
if room.room_type() == RoomType::Joined {
|
||||||
Some(Self {
|
Some(Self {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{room::Common, Client, Result, Room, RoomType};
|
use crate::{room::Common, BaseRoom, Client, Result, RoomType};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use matrix_sdk_common::api::r0::membership::forget_room;
|
use matrix_sdk_common::api::r0::membership::forget_room;
|
||||||
|
@ -19,7 +19,7 @@ impl Left {
|
||||||
/// * `client` - The client used to make requests.
|
/// * `client` - The client used to make requests.
|
||||||
///
|
///
|
||||||
/// * `room` - The underlaying room.
|
/// * `room` - The underlaying room.
|
||||||
pub fn new(client: Client, room: Room) -> Option<Self> {
|
pub fn new(client: Client, room: BaseRoom) -> Option<Self> {
|
||||||
// TODO: Make this private
|
// TODO: Make this private
|
||||||
if room.room_type() == RoomType::Left {
|
if room.room_type() == RoomType::Left {
|
||||||
Some(Self {
|
Some(Self {
|
||||||
|
|
Loading…
Reference in New Issue