MCPcopy Create free account
hub / github.com/chatmail/core / truncate_msg_text

Function truncate_msg_text

src/tools.rs:141–151  ·  view source on GitHub ↗

Shortens a message text if necessary according to the configuration. Adds "[...]" to the end of the shortened text. Returns the resulting text and a bool telling whether a truncation was done.

(context: &Context, text: String)

Source from the content-addressed store, hash-verified

139///
140/// Returns the resulting text and a bool telling whether a truncation was done.
141pub(crate) async fn truncate_msg_text(context: &Context, text: String) -> Result<(String, bool)> {
142 if context.get_config_bool(Config::Bot).await? {
143 return Ok((text, false));
144 }
145 // Truncate text if it has too many lines
146 Ok(truncate_by_lines(
147 text,
148 constants::DC_DESIRED_TEXT_LINES,
149 constants::DC_DESIRED_TEXT_LINE_LEN,
150 ))
151}
152
153/* ******************************************************************************
154 * date/time tools

Callers 2

prepare_msg_rawMethod · 0.85

Calls 2

truncate_by_linesFunction · 0.85
get_config_boolMethod · 0.80

Tested by

no test coverage detected