diff --git a/src/error.rs b/src/error.rs index 84db214..f89cf94 100644 --- a/src/error.rs +++ b/src/error.rs @@ -33,9 +33,6 @@ pub enum Error { SessionAlreadyExists(Session), /// Raised when fetching an occupant with a nickname that isn't assigned in the room. ParticipantNotFound(String), - /// Raised whenever an operation is applied to a session which isn't the primary session, used - /// for Multi-Session Nick support. - SecondarySession(Session), /// The origin (from) JID isn't of the expected for (bare or full) InvalidOriginJid, /// The destination (to) JID isn't of the expected for (bare or full) @@ -60,7 +57,6 @@ impl fmt::Display for Error { Error::NonexistantSession(err) => write!(f, "Session doesn't exist: {:?}", err), Error::SessionAlreadyExists(err) => write!(f, "Session already exist: {:?}", err), Error::ParticipantNotFound(err) => write!(f, "Participant not found: {}", err), - Error::SecondarySession(err) => write!(f, "Secondary session: {:?}", err), Error::InvalidOriginJid => write!(f, "Invalid origin JID"), Error::InvalidDestinationJid => write!(f, "Invalid destination JID"), Error::UnhandledIq(err) => write!(f, "Unhandled Iq: {:?}", err), diff --git a/src/occupant.rs b/src/occupant.rs index e82c42a..9b416b7 100644 --- a/src/occupant.rs +++ b/src/occupant.rs @@ -92,12 +92,8 @@ impl Occupant { for (i, session) in self.sessions.iter().enumerate() { if &own_session == session { - if i == 0 { - // Primary session - self.sessions[0] = own_session; - return Ok(()); - } - return Err(Error::SecondarySession(own_session)); + self.sessions[i] = own_session; + return Ok(()); } } @@ -130,9 +126,7 @@ impl Occupant { #[cfg(test)] mod tests { use super::*; - use crate::tests::templates::{ - LOUISE_FULL1, LOUISE_FULL2, LOUISE_NICK, LOUISE_ROOM1_PART, ROOM1_BARE, - }; + use crate::tests::templates::{LOUISE_FULL1, LOUISE_FULL2, LOUISE_ROOM1_PART}; use xmpp_parsers::{ muc::{ user::{Affiliation, Item as MucItem, Role}, @@ -191,16 +185,11 @@ mod tests { .unwrap(); match occupant.update_presence(presence2.clone()) { - Err(Error::SecondarySession(session)) if session.real() == &*LOUISE_FULL2 => (), - err => panic!( - "Should return Error::SecondarySession(Session {{ {:?} }}), returned: {:?}", - *LOUISE_FULL2, err, - ), + Ok(()) => (), + err => panic!("Error: {:?}", err), } - assert_eq!( - occupant.sessions[1], - Session::try_from(presence2.clone()).unwrap() - ); + + assert_eq!(occupant.sessions[1].presence, presence2); let presence_leave_louise2 = PresenceFull::try_from( Presence::new(PresenceType::Unavailable) @@ -213,7 +202,7 @@ mod tests { match occupant.update_presence(presence2) { Err(Error::NonexistantSession(session)) if session.real() == &*LOUISE_FULL2 => (), err => panic!( - "Should return Error::SecondarySession(Session {{ {:?} }}), returned: {:?}", + "Should return Error::NonexistantSession(Session {{ {:?} }}), returned: {:?}", *LOUISE_FULL2, err, ), } diff --git a/src/room.rs b/src/room.rs index f9ae1b7..f02237b 100644 --- a/src/room.rs +++ b/src/room.rs @@ -317,7 +317,7 @@ impl Room { let occupant = self.get_mut_occupant(&session)?; match occupant.update_presence(session.presence.clone()) { - Ok(_) | Err(Error::SecondarySession(_)) => (), + Ok(_) => (), err => err?, }