Skip to content

Commit

Permalink
news: Properly take care of unicode string splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
haecker-felix committed Nov 3, 2023
1 parent 2746373 commit e1dadab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -19,3 +19,4 @@ de.haeckerfelix.Hebbot.json
/project_template.md
./section_template.md
/section_template.md
.flatpak-builder
1 change: 0 additions & 1 deletion src/bot.rs
Expand Up @@ -586,7 +586,6 @@ impl Bot {
let message = {
let is_editor = self.is_editor(member).await;
let mut news_store = self.news_store.lock().unwrap();
let redacted_event_id = redacted_event_id;
let link = self.message_link(redacted_event_id);

// Redaction / deletion of the news entry itself
Expand Down
10 changes: 9 additions & 1 deletion src/news.rs
Expand Up @@ -47,7 +47,15 @@ impl News {

pub fn message_summary(&self) -> String {
if self.message.borrow().len() > 60 {
format!("{} …", self.message.borrow().clone().split_at(50).0)
format!(
"{} …",
self.message
.borrow()
.clone()
.chars()
.take(50)
.collect::<String>()
)
} else {
self.message.borrow().clone()
}
Expand Down

0 comments on commit e1dadab

Please sign in to comment.