1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use matrix_sdk::ruma::{
MilliSecondsSinceUnixEpoch, OwnedMxcUri, OwnedRoomAliasId, OwnedRoomId, OwnedUserId,
};
use serde::Serialize;
use crate::models::room_display_name::FrontendRoomDisplayName;
#[derive(Clone, Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InvitedRoomInfo {
/// The matrix ID of this room.
pub room_id: OwnedRoomId,
/// The displayable name of this room, if known.
pub room_name: FrontendRoomDisplayName,
/// The canonical alias for this room, if any.
pub canonical_alias: Option<OwnedRoomAliasId>,
/// The alternative aliases for this room, if any.
pub alt_aliases: Vec<OwnedRoomAliasId>,
/// The avatar for this room: either an array of bytes holding the avatar image
/// or a string holding the first Unicode character of the room name.
pub room_avatar: Option<OwnedMxcUri>,
/// Info about the user who invited us to this room, if available.
pub inviter_info: Option<InviterInfo>,
/// The timestamp and Html text content of the latest message in this room.
pub latest: Option<(MilliSecondsSinceUnixEpoch, String)>,
/// The state of this how this invite is being handled by the client backend
/// and what should be shown in the UI.
pub invite_state: InviteState,
/// Whether this is an invite to a direct room.
pub is_direct: bool,
}
/// Info about the user who invited us to a room.
#[derive(Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InviterInfo {
pub user_id: OwnedUserId,
pub display_name: Option<String>,
pub avatar: Option<OwnedMxcUri>,
}
impl std::fmt::Debug for InviterInfo {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("InviterInfo")
.field("user_id", &self.user_id)
.field("display_name", &self.display_name)
.field("avatar?", &self.avatar.is_some())
.finish()
}
}
/// The state of a pending invite.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase", rename_all_fields = "camelCase")]
pub enum InviteState {
/// Waiting for the user to accept or decline the invite.
#[default]
WaitingOnUserInput,
/// Waiting for the server to respond to the user's "join room" action.
_WaitingForJoinResult,
/// Waiting for the server to respond to the user's "leave room" action.
_WaitingForLeaveResult,
/// The invite was accepted and the room was successfully joined.
/// We're now waiting for our client to receive the joined room from the homeserver.
_WaitingForJoinedRoom,
/// The invite was declined and the room was successfully left.
/// This should result in the InviteScreen being closed.
_RoomLeft,
}