|
|
|
@ -1,4 +1,4 @@ |
|
|
|
use crate::room;
|
|
|
|
use crate::room::Room;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use solstice_proto::User;
|
|
|
|
|
|
|
|
@ -20,6 +20,7 @@ pub enum Response { |
|
|
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
|
pub struct RoomJoinResponse {
|
|
|
|
pub room_name: String,
|
|
|
|
pub room: Room,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
|
@ -60,7 +61,7 @@ pub enum LoginStatusResponse { |
|
|
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
|
pub struct RoomListResponse {
|
|
|
|
/// The list of (room name, room data) pairs.
|
|
|
|
pub rooms: Vec<(String, room::Room)>,
|
|
|
|
pub rooms: Vec<(String, Room)>,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// This structure contains a message said in a chat room the user is a member
|
|
|
|
@ -172,10 +173,36 @@ mod tests { |
|
|
|
#[test]
|
|
|
|
fn deserialize_room_join_response() {
|
|
|
|
assert_eq!(
|
|
|
|
serde_json::from_str::<RoomJoinResponse>(r#"{ "room_name": "bleep" }"#)
|
|
|
|
.unwrap(),
|
|
|
|
serde_json::from_str::<RoomJoinResponse>(
|
|
|
|
r#"{
|
|
|
|
"room_name": "bleep",
|
|
|
|
"room": {
|
|
|
|
"membership": "Joining",
|
|
|
|
"visibility": "PrivateOwned",
|
|
|
|
"operated": false,
|
|
|
|
"user_count": 3,
|
|
|
|
"owner": null,
|
|
|
|
"operators": [],
|
|
|
|
"members": [],
|
|
|
|
"messages": [],
|
|
|
|
"tickers": []
|
|
|
|
}
|
|
|
|
}"#
|
|
|
|
)
|
|
|
|
.unwrap(),
|
|
|
|
RoomJoinResponse {
|
|
|
|
room_name: "bleep".to_string(),
|
|
|
|
room: Room {
|
|
|
|
membership: Membership::Joining,
|
|
|
|
visibility: Visibility::PrivateOwned,
|
|
|
|
operated: false,
|
|
|
|
user_count: 3,
|
|
|
|
owner: None,
|
|
|
|
operators: HashSet::new(),
|
|
|
|
members: HashSet::new(),
|
|
|
|
messages: vec![],
|
|
|
|
tickers: vec![],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|