mirror of
https://git.dirksys.ovh/dirk/bankserver.git
synced 2025-12-20 02:59:20 +01:00
use new regex for interop users
This commit is contained in:
parent
791ff84515
commit
a6cdd5377b
@ -132,7 +132,8 @@ pub enum AccountTarget {
|
||||
#[cfg_attr(feature = "schemas", derive(schemars::JsonSchema))]
|
||||
#[cfg_attr(feature = "schemas", serde(untagged))]
|
||||
pub enum UnvalidatedAccountTarget {
|
||||
Interop(#[garde(pattern("^thc:.+$"))] String),
|
||||
/// Interop user
|
||||
Interop(#[garde(pattern("^.{2,}@[a-z0-9]{2,4}$"))] String),
|
||||
Selector(#[garde(dive)] UnvalidatedAccountSelector),
|
||||
}
|
||||
|
||||
@ -150,7 +151,7 @@ impl<'de> Deserialize<'de> for UnvalidatedAccountTarget {
|
||||
Ok(match AccountTargetHelper::deserialize(deserializer)? {
|
||||
AccountTargetHelper::Text(text) => {
|
||||
// TODO: don't hardcode prefix
|
||||
if let Some(text) = text.strip_prefix("thc:") {
|
||||
if let Some(text) = text.strip_suffix("@thc") {
|
||||
Self::Interop(text.into())
|
||||
} else {
|
||||
Self::Selector(UnvalidatedAccountSelector::Username(Name(text)))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user