Add NoticeMessageEventContent::html and TextMessageEventContent::html

This commit is contained in:
Jonas Platte 2020-08-13 19:46:05 +02:00
parent 4a5272e37b
commit d36dcdb202
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67

View File

@ -232,6 +232,15 @@ impl NoticeMessageEventContent {
pub fn plain(body: impl Into<String>) -> Self { pub fn plain(body: impl Into<String>) -> Self {
Self { body: body.into(), formatted: None, relates_to: None } Self { body: body.into(), formatted: None, relates_to: None }
} }
/// A convenience constructor to create an html notice.
pub fn html(body: impl Into<String>, html_body: impl Into<String>) -> Self {
Self {
body: body.into(),
formatted: Some(FormattedBody::html(html_body)),
relates_to: None,
}
}
} }
/// The payload for a server notice message. /// The payload for a server notice message.
@ -339,6 +348,15 @@ impl TextMessageEventContent {
Self { body: body.into(), formatted: None, relates_to: None } Self { body: body.into(), formatted: None, relates_to: None }
} }
/// A convenience constructor to create an html message.
pub fn html(body: impl Into<String>, html_body: impl Into<String>) -> Self {
Self {
body: body.into(),
formatted: Some(FormattedBody::html(html_body)),
relates_to: None,
}
}
/// A convenience constructor to create a plain text message. /// A convenience constructor to create a plain text message.
#[deprecated = "Renamed to plain"] #[deprecated = "Renamed to plain"]
pub fn new_plain(body: impl Into<String>) -> Self { pub fn new_plain(body: impl Into<String>) -> Self {