muc::History::disabled() and muc::Muc::without_history() disable legacy history on MUC join (#77)

This commit is contained in:
xmppftw 2023-06-03 12:14:51 +02:00 committed by xmpp ftw
parent c8dcf5e7a7
commit 8c9448b46d
2 changed files with 13 additions and 0 deletions

View file

@ -9,6 +9,8 @@ xxx
- Presence::with_payload builds a payload into the presence (#79)
- Message now has constructors for each type ; Message::new still builds a Chat type (#78)
- Message::with_body builder method appends a body in a given language to the message (#78)
- muc::History::disabled method requests 0 maxchars history from MUC (#77)
- muc::Muc::without_history builder method requests 0 maxchars history from MUC (#77)
* Breaking changes:
- Removed the 'serde' feature. Add it directly by using 'jid'.
`jid = { version = "*", features = ["serde"] }`.

View file

@ -33,6 +33,11 @@ impl History {
History::default()
}
/// Don't request history from MUC
pub fn disabled() -> Self {
Self::new().with_maxchars(0)
}
/// Set how many characters of history to send.
pub fn with_maxchars(mut self, maxchars: u32) -> Self {
self.maxchars = Some(maxchars);
@ -89,6 +94,12 @@ impl Muc {
self.history = Some(history);
self
}
/// Join a room without history.
pub fn without_history(mut self) -> Self {
self.history = Some(History::disabled());
self
}
}
#[cfg(test)]