- Save thinking_content as {"__chunks__": [{type, content}]} for replay
- Tool call sanitization — don't expose raw results to frontend
- Billing record_ai_usage integration
- Room service module refactoring into service/ directory
49 lines
1.5 KiB
Rust
49 lines
1.5 KiB
Rust
use uuid::Uuid;
|
|
|
|
use super::patterns::{mention_bracket_re, mention_tag_re, user_mention_re};
|
|
|
|
/// Extracts user UUIDs from all mention formats:
|
|
/// - Legacy: `<user>uuid</user>`
|
|
/// - Legacy: `<mention type="user" id="uuid">label</mention>`
|
|
/// - New: `@[user:uuid:label]`
|
|
pub fn extract_mentions(content: &str) -> Vec<Uuid> {
|
|
let mut mentioned = Vec::new();
|
|
|
|
for cap in user_mention_re().captures_iter(content) {
|
|
if let Some(inner) = cap.get(1) {
|
|
let token = inner.as_str().trim();
|
|
if let Ok(uuid) = Uuid::parse_str(token) {
|
|
if !mentioned.contains(&uuid) {
|
|
mentioned.push(uuid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for cap in mention_tag_re().captures_iter(content) {
|
|
if let (Some(type_m), Some(id_m)) = (cap.get(1), cap.get(2)) {
|
|
if type_m.as_str() == "user" {
|
|
if let Ok(uuid) = Uuid::parse_str(id_m.as_str().trim()) {
|
|
if !mentioned.contains(&uuid) {
|
|
mentioned.push(uuid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for cap in mention_bracket_re().captures_iter(content) {
|
|
if let (Some(type_m), Some(id_m)) = (cap.get(1), cap.get(2)) {
|
|
if type_m.as_str() == "user" {
|
|
if let Ok(uuid) = Uuid::parse_str(id_m.as_str().trim()) {
|
|
if !mentioned.contains(&uuid) {
|
|
mentioned.push(uuid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
mentioned
|
|
}
|