diff --git a/src/domain/username.rs b/src/domain/username.rs index 0a75fb7..5e782b2 100644 --- a/src/domain/username.rs +++ b/src/domain/username.rs @@ -1,6 +1,8 @@ use std::ops::Deref; use derive_more::{Constructor, From}; +const LTR_MARK: char = '\u{200E}'; + #[derive(Debug, Clone, Constructor, From, Eq, PartialEq)] pub struct Username(String); @@ -14,7 +16,8 @@ impl Username { } pub fn escaped(&self) -> String { - teloxide::utils::html::escape(self.value_ref()) + let ltr_name = format!("{LTR_MARK}{}{LTR_MARK}", self.value_ref()); + teloxide::utils::html::escape(<r_name) } } diff --git a/src/handlers/dick.rs b/src/handlers/dick.rs index e4098f9..40632ec 100644 --- a/src/handlers/dick.rs +++ b/src/handlers/dick.rs @@ -13,13 +13,12 @@ use teloxide::types::{CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup, use page::{InvalidPage, Page}; use crate::{config, metrics, repo}; -use crate::domain::LanguageCode; +use crate::domain::{LanguageCode, Username}; use crate::handlers::{HandlerResult, reply_html, utils}; use crate::handlers::utils::{callbacks, Incrementor, page}; use crate::repo::{ChatIdPartiality, UID}; const TOMORROW_SQL_CODE: &str = "GD0E1"; -const LTR_MARK: char = '\u{200E}'; const CALLBACK_PREFIX_TOP_PAGE: &str = "top:page:"; #[derive(BotCommands, Clone)] @@ -133,8 +132,7 @@ pub(crate) async fn top_impl(repos: &repo::Repositories, config: &config::AppCon .take(config.top_limit as usize) .enumerate() .map(|(i, d)| { - let ltr_name = format!("{LTR_MARK}{}{LTR_MARK}", d.owner_name); - let escaped_name = teloxide::utils::html::escape(<r_name); + let escaped_name = Username::new(d.owner_name).escaped(); let name = if from.id == >::into(d.owner_uid) { format!("{escaped_name}") } else {