forked from jmug/stoatchat
Shorten regex and adapt capture evaluation
This commit is contained in:
@@ -30,7 +30,7 @@ pub struct Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref RE_ULID: Regex = Regex::new(r"<@([0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26})>").unwrap();
|
static ref RE_ULID: Regex = Regex::new(r"<@([0-9A-Z]{26})>").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/<target>/messages", data = "<message>")]
|
#[post("/<target>/messages", data = "<message>")]
|
||||||
@@ -80,9 +80,10 @@ pub async fn message_send(_r: RateLimited<'_>, user: User, target: Ref, message:
|
|||||||
let id = Ulid::new().to_string();
|
let id = Ulid::new().to_string();
|
||||||
|
|
||||||
let mut mentions = HashSet::new();
|
let mut mentions = HashSet::new();
|
||||||
if let Some(captures) = RE_ULID.captures_iter(&message.content).next() {
|
for capture in RE_ULID.captures_iter(&message.content) {
|
||||||
// ! FIXME: in the future, verify in group so we can send out push
|
if let Some(mention) = capture.get(1) {
|
||||||
mentions.insert(captures[1].to_string());
|
mentions.insert(mention.as_str().to_string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut replies = HashSet::new();
|
let mut replies = HashSet::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user