Make fallback user mentions support also match against the bot's room-specific username

It seems like Element iOS benefits from this.
This commit is contained in:
Slavi Pantaleev
2024-10-03 16:28:49 +03:00
parent 393be9be5a
commit d9a045a5e4
5 changed files with 61 additions and 26 deletions

View File

@@ -383,24 +383,10 @@ async fn handle_stage_text_generation(
_ => vec![],
};
let bot_display_name = bot
.room_display_name_fetcher()
.own_display_name_in_room(message_context.room())
.await;
let bot_display_name = match bot_display_name {
Ok(value) => value,
Err(err) => {
tracing::warn!(
?err,
"Failed to fetch bot display name. Proceeding without it"
);
None
}
};
let bot_user_prefixes_to_strip =
create_list_of_bot_user_prefixes_to_strip(bot.user_id(), &bot_display_name);
let bot_user_prefixes_to_strip = create_list_of_bot_user_prefixes_to_strip(
bot.user_id(),
message_context.bot_display_name(),
);
let allowed_users = match controller_type {
// Regular chat completion only operates on messages from allowed users.