From d36dcdb202b547270f3ddb4a95ace47aa48d6907 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 13 Aug 2020 19:46:05 +0200 Subject: [PATCH] Add NoticeMessageEventContent::html and TextMessageEventContent::html --- ruma-events/src/room/message.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ruma-events/src/room/message.rs b/ruma-events/src/room/message.rs index a36535ca..9bf259eb 100644 --- a/ruma-events/src/room/message.rs +++ b/ruma-events/src/room/message.rs @@ -232,6 +232,15 @@ impl NoticeMessageEventContent { pub fn plain(body: impl Into) -> Self { Self { body: body.into(), formatted: None, relates_to: None } } + + /// A convenience constructor to create an html notice. + pub fn html(body: impl Into, html_body: impl Into) -> Self { + Self { + body: body.into(), + formatted: Some(FormattedBody::html(html_body)), + relates_to: None, + } + } } /// The payload for a server notice message. @@ -339,6 +348,15 @@ impl TextMessageEventContent { Self { body: body.into(), formatted: None, relates_to: None } } + /// A convenience constructor to create an html message. + pub fn html(body: impl Into, html_body: impl Into) -> Self { + Self { + body: body.into(), + formatted: Some(FormattedBody::html(html_body)), + relates_to: None, + } + } + /// A convenience constructor to create a plain text message. #[deprecated = "Renamed to plain"] pub fn new_plain(body: impl Into) -> Self {