Commit 195cabfdc3
Unregistered key
Layout: unified · split
.github/workflows/ci.yml +1
| @@ -45,6 +45,7 @@ jobs: | |||
| 45 | with: | 45 | with: |
| 46 | github_token: ${{ secrets.GITHUB_TOKEN }} | 46 | github_token: ${{ secrets.GITHUB_TOKEN }} |
| 47 | reporter: 'github-check' | 47 | reporter: 'github-check' |
| 48 | clippy_flags: --all-targets -- -D warnings | ||
| 48 | - name: Run tests | 49 | - name: Run tests |
| 49 | run: cargo test --locked | 50 | run: cargo test --locked |
| 50 | 51 | ||
src/notifications.rs +10 −10
| @@ -328,6 +328,16 @@ fn thread_notification_body(body: String, is_thread: bool) -> String { | |||
| 328 | } | 328 | } |
| 329 | } | 329 | } |
| 330 | 330 | ||
| 331 | fn truncate(s: String) -> String { | ||
| 332 | static MAX_LENGTH: usize = 5000; | ||
| 333 | if s.graphemes(true).count() > MAX_LENGTH { | ||
| 334 | let truncated: String = s.graphemes(true).take(MAX_LENGTH).collect(); | ||
| 335 | truncated + "..." | ||
| 336 | } else { | ||
| 337 | s | ||
| 338 | } | ||
| 339 | } | ||
| 340 | |||
| 331 | #[cfg(test)] | 341 | #[cfg(test)] |
| 332 | mod tests { | 342 | mod tests { |
| 333 | use super::thread_notification_body; | 343 | use super::thread_notification_body; |
| @@ -338,13 +348,3 @@ mod tests { | |||
| 338 | assert_eq!(thread_notification_body("hello".into(), false), "hello"); | 348 | assert_eq!(thread_notification_body("hello".into(), false), "hello"); |
| 339 | } | 349 | } |
| 340 | } | 350 | } |
| 341 | |||
| 342 | fn truncate(s: String) -> String { | ||
| 343 | static MAX_LENGTH: usize = 5000; | ||
| 344 | if s.graphemes(true).count() > MAX_LENGTH { | ||
| 345 | let truncated: String = s.graphemes(true).take(MAX_LENGTH).collect(); | ||
| 346 | truncated + "..." | ||
| 347 | } else { | ||
| 348 | s | ||
| 349 | } | ||
| 350 | } | ||