storkit: merge 463_story_configurable_rate_limit_notification_suppression

This commit is contained in:
dave
2026-04-03 12:56:39 +00:00
parent f199bf3979
commit 8059df8330
4 changed files with 234 additions and 14 deletions
+12 -13
View File
@@ -55,19 +55,18 @@ pub fn strip_bot_mention<'a>(message: &'a str, bot_name: &str, bot_user_id: &str
// Try Element Markdown mention pill format:
// "[DisplayName](https://matrix.to/#/@user:server) rest"
if trimmed.starts_with('[') {
if let Some(after_label) = trimmed.find("](https://matrix.to/#/") {
let url_start = after_label + 2; // skip "]("
let url_content = &trimmed[url_start..]; // "https://matrix.to/#/@user:server) rest"
if let Some(close_paren) = url_content.find(')') {
let url = &url_content[..close_paren]; // "https://matrix.to/#/@user:server"
let matrix_prefix = "https://matrix.to/#/";
if url.starts_with(matrix_prefix) {
let mentioned_id = &url[matrix_prefix.len()..];
if mentioned_id.eq_ignore_ascii_case(bot_user_id) {
let rest = &url_content[close_paren + 1..];
return strip_mention_separator(rest);
}
if trimmed.starts_with('[')
&& let Some(after_label) = trimmed.find("](https://matrix.to/#/")
{
let url_start = after_label + 2; // skip "]("
let url_content = &trimmed[url_start..]; // "https://matrix.to/#/@user:server) rest"
if let Some(close_paren) = url_content.find(')') {
let url = &url_content[..close_paren]; // "https://matrix.to/#/@user:server"
let matrix_prefix = "https://matrix.to/#/";
if let Some(mentioned_id) = url.strip_prefix(matrix_prefix) {
if mentioned_id.eq_ignore_ascii_case(bot_user_id) {
let rest = &url_content[close_paren + 1..];
return strip_mention_separator(rest);
}
}
}