events: Update reply ctor argument types
This commit is contained in:
parent
b4226f882b
commit
b7334edaf7
@ -9,6 +9,8 @@ Breaking changes:
|
|||||||
* The `new` constructor now also has a body parameter
|
* The `new` constructor now also has a body parameter
|
||||||
* Rename `*ToDeviceEventContent` structs to `ToDevice*Content`
|
* Rename `*ToDeviceEventContent` structs to `ToDevice*Content`
|
||||||
* Remove unneeded redacted event content enums
|
* Remove unneeded redacted event content enums
|
||||||
|
* Update `reply` and `html_reply` types to `impl Display` on `RoomMessageEventContent`'s reply
|
||||||
|
constructors
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Types for the `m.room.message` event.
|
//! Types for the `m.room.message` event.
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::{borrow::Cow, fmt};
|
||||||
|
|
||||||
use indoc::formatdoc;
|
use indoc::formatdoc;
|
||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
@ -81,10 +81,10 @@ impl RoomMessageEventContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a plain text reply to a message.
|
/// Creates a plain text reply to a message.
|
||||||
pub fn text_reply_plain(reply: impl Into<String>, original_message: &RoomMessageEvent) -> Self {
|
pub fn text_reply_plain(reply: impl fmt::Display, original_message: &RoomMessageEvent) -> Self {
|
||||||
let quoted = get_plain_quote_fallback(original_message);
|
let quoted = get_plain_quote_fallback(original_message);
|
||||||
|
|
||||||
let body = format!("{}\n\n{}", quoted, reply.into());
|
let body = format!("{}\n\n{}", quoted, reply);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
relates_to: Some(Relation::Reply {
|
relates_to: Some(Relation::Reply {
|
||||||
@ -96,15 +96,15 @@ impl RoomMessageEventContent {
|
|||||||
|
|
||||||
/// Creates a html text reply to a message.
|
/// Creates a html text reply to a message.
|
||||||
pub fn text_reply_html(
|
pub fn text_reply_html(
|
||||||
reply: impl Into<String>,
|
reply: impl fmt::Display,
|
||||||
html_reply: impl Into<String>,
|
html_reply: impl fmt::Display,
|
||||||
original_message: &RoomMessageEvent,
|
original_message: &RoomMessageEvent,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let quoted = get_plain_quote_fallback(original_message);
|
let quoted = get_plain_quote_fallback(original_message);
|
||||||
let quoted_html = get_html_quote_fallback(original_message);
|
let quoted_html = get_html_quote_fallback(original_message);
|
||||||
|
|
||||||
let body = format!("{}\n\n{}", quoted, reply.into());
|
let body = format!("{}\n\n{}", quoted, reply);
|
||||||
let html_body = format!("{}\n\n{}", quoted_html, html_reply.into());
|
let html_body = format!("{}\n\n{}", quoted_html, html_reply);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
relates_to: Some(Relation::Reply {
|
relates_to: Some(Relation::Reply {
|
||||||
@ -116,12 +116,12 @@ impl RoomMessageEventContent {
|
|||||||
|
|
||||||
/// Creates a plain text notice reply to a message.
|
/// Creates a plain text notice reply to a message.
|
||||||
pub fn notice_reply_plain(
|
pub fn notice_reply_plain(
|
||||||
reply: impl Into<String>,
|
reply: impl fmt::Display,
|
||||||
original_message: &RoomMessageEvent,
|
original_message: &RoomMessageEvent,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let quoted = get_plain_quote_fallback(original_message);
|
let quoted = get_plain_quote_fallback(original_message);
|
||||||
|
|
||||||
let body = format!("{}\n\n{}", quoted, reply.into());
|
let body = format!("{}\n\n{}", quoted, reply);
|
||||||
Self {
|
Self {
|
||||||
relates_to: Some(Relation::Reply {
|
relates_to: Some(Relation::Reply {
|
||||||
in_reply_to: InReplyTo { event_id: original_message.event_id.clone() },
|
in_reply_to: InReplyTo { event_id: original_message.event_id.clone() },
|
||||||
@ -132,15 +132,15 @@ impl RoomMessageEventContent {
|
|||||||
|
|
||||||
/// Creates a html text notice reply to a message.
|
/// Creates a html text notice reply to a message.
|
||||||
pub fn notice_reply_html(
|
pub fn notice_reply_html(
|
||||||
reply: impl Into<String>,
|
reply: impl fmt::Display,
|
||||||
html_reply: impl Into<String>,
|
html_reply: impl fmt::Display,
|
||||||
original_message: &RoomMessageEvent,
|
original_message: &RoomMessageEvent,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let quoted = get_plain_quote_fallback(original_message);
|
let quoted = get_plain_quote_fallback(original_message);
|
||||||
let quoted_html = get_html_quote_fallback(original_message);
|
let quoted_html = get_html_quote_fallback(original_message);
|
||||||
|
|
||||||
let body = format!("{}\n\n{}", quoted, reply.into());
|
let body = format!("{}\n\n{}", quoted, reply);
|
||||||
let html_body = format!("{}\n\n{}", quoted_html, html_reply.into());
|
let html_body = format!("{}\n\n{}", quoted_html, html_reply);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
relates_to: Some(Relation::Reply {
|
relates_to: Some(Relation::Reply {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user