use matrix_sdk::ruma::{OwnedEventId, OwnedRoomId, OwnedUserId};
#[derive(Clone, Debug)]
pub struct RoomSummary {
pub room_id: OwnedRoomId,
pub display_name: String,
pub avatar_url: Option<String>,
pub topic: Option<String>,
pub is_direct: bool,
pub is_favorite: bool,
pub is_encrypted: bool,
pub is_tombstoned: bool,
pub tombstone_successor: Option<OwnedRoomId>,
pub tombstone_body: Option<String>,
pub unread_count: u64,
pub highlight_count: u64,
pub last_activity_ts: Option<u64>,
pub last_event_preview: Option<String>,
pub last_event_sender: Option<String>,
pub member_count: u64,
pub typing_members: Vec<String>,
pub notification_level: NotificationLevel,
pub parent_spaces: Vec<OwnedRoomId>,
pub membership: RoomMembership,
}
#[derive(Clone, Debug, PartialEq)]
pub enum RoomMembership {
Joined,
Invited,
Left,
Knocked,
}
#[derive(Clone, Debug, PartialEq)]
pub enum NotificationLevel {
Default,
AllMessages,
MentionsAndKeywords,
Mute,
}
impl Default for NotificationLevel {
fn default() -> Self {
Self::Default
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum RoomFilter {
All,
DirectMessages,
Rooms,
Favorites,
Space(OwnedRoomId),
}
#[derive(Clone, Debug, PartialEq)]
pub enum RoomSortOrder {
Activity,
Alphabetical,
Unread,
}
#[derive(Clone, Debug)]
pub struct RoomMember {
pub user_id: OwnedUserId,
pub display_name: Option<String>,
pub avatar_url: Option<String>,
pub power_level: i64,
pub membership: MemberMembership,
pub is_ignored: bool,
}
#[derive(Clone, Debug, PartialEq)]
pub enum MemberMembership {
Join,
Invite,
Leave,
Ban,
Knock,
}
#[derive(Clone, Debug)]
pub enum TimelineItemKind {
Event(EventTimelineData),
DaySeparator(String),
ReadMarker,
Loading,
}
#[derive(Clone, Debug)]
pub struct EventTimelineData {
pub event_id: Option<OwnedEventId>,
pub sender: OwnedUserId,
pub sender_display_name: String,
pub sender_avatar_url: Option<String>,
pub timestamp: u64,
pub content: TimelineContent,
pub reactions: Vec<ReactionGroup>,
pub is_edited: bool,
pub reply_to: Option<Box<ReplyPreview>>,
pub read_receipts: Vec<ReadReceipt>,
pub send_state: SendState,
pub is_own_message: bool,
}
#[derive(Clone, Debug, PartialEq)]
pub enum TimelineContent {
Text {
body: String,
formatted_body: Option<String>,
},
Image {
body: String,
url: Option<String>,
thumbnail_url: Option<String>,
blurhash: Option<String>,
width: Option<u32>,
height: Option<u32>,
},
File {
body: String,
url: Option<String>,
size: Option<u64>,
mimetype: Option<String>,
},
Audio {
body: String,
url: Option<String>,
duration_ms: Option<u64>,
},
Video {
body: String,
url: Option<String>,
thumbnail_url: Option<String>,
width: Option<u32>,
height: Option<u32>,
duration_ms: Option<u64>,
},
Emote {
body: String,
formatted_body: Option<String>,
},
Notice {
body: String,
formatted_body: Option<String>,
},
StateEvent { description: String },
Redacted { reason: Option<String> },
EncryptionError { message: String },
Sticker { body: String, url: Option<String> },
Poll {
question: String,
answers: Vec<PollAnswer>,
kind: PollKind,
is_ended: bool,
},
Location {
body: String,
geo_uri: String,
description: Option<String>,
},
VoiceMessage {
body: String,
url: Option<String>,
duration_ms: Option<u64>,
waveform: Vec<u16>,
},
}
#[derive(Clone, Debug, PartialEq)]
pub struct PollAnswer {
pub id: String,
pub text: String,
pub vote_count: u32,
pub voted_by_me: bool,
}
#[derive(Clone, Debug, PartialEq)]
pub enum PollKind {
Disclosed,
Undisclosed,
}
#[derive(Clone, Debug, PartialEq)]
pub struct ReactionGroup {
pub key: String,
pub count: u64,
pub user_reacted: bool,
pub senders: Vec<OwnedUserId>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct ReplyPreview {
pub event_id: OwnedEventId,
pub sender_name: String,
pub body: String,
}
#[derive(Clone, Debug, PartialEq)]
pub struct ReadReceipt {
pub user_id: OwnedUserId,
pub display_name: Option<String>,
pub avatar_url: Option<String>,
pub timestamp: Option<u64>,
}
#[derive(Clone, Debug, PartialEq)]
pub enum SendState {
None,
Pending,
Sent,
Failed(String),
}
#[derive(Clone, Debug, PartialEq)]
pub struct EditingMessage {
pub event_id: OwnedEventId,
pub room_id: OwnedRoomId,
pub original_body: String,
}
#[derive(Clone, Debug, PartialEq)]
pub struct ReplyingTo {
pub event_id: OwnedEventId,
pub sender_name: String,
pub body: String,
pub room_id: OwnedRoomId,
}
impl TimelineContent {
pub fn body_text(&self) -> String {
match self {
TimelineContent::Text { body, .. } => body.clone(),
TimelineContent::Image { body, .. } => body.clone(),
TimelineContent::File { body, .. } => body.clone(),
TimelineContent::Audio { body, .. } => body.clone(),
TimelineContent::Video { body, .. } => body.clone(),
TimelineContent::Emote { body, .. } => body.clone(),
TimelineContent::Notice { body, .. } => body.clone(),
TimelineContent::StateEvent { description } => description.clone(),
TimelineContent::Redacted { .. } => "Deleted message".to_string(),
TimelineContent::EncryptionError { .. } => "Encrypted message".to_string(),
TimelineContent::Sticker { body, .. } => body.clone(),
TimelineContent::Poll { question, .. } => format!("Poll: {question}"),
TimelineContent::Location { body, .. } => body.clone(),
TimelineContent::VoiceMessage { body, .. } => body.clone(),
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum PresenceStatus {
Online,
Unavailable,
Offline,
}
#[derive(Clone, Debug)]
pub struct SpaceSummary {
pub room_id: OwnedRoomId,
pub display_name: String,
pub avatar_url: Option<String>,
pub child_room_ids: Vec<OwnedRoomId>,
}