@ -6,15 +6,15 @@ use rand::{distributions::Alphanumeric, thread_rng, Rng};
use regex ::{ Regex , RegexBuilder } ;
lazy_static ! {
static ref EMAIL_REGEX : Regex = Regex ::new ( r"^[a-zA-Z0-9.!#$%&’ *+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$" ) . unwrap ( ) ;
static ref SLUR_REGEX : Regex = RegexBuilder ::new ( r"(fag(g|got|tard)?\b|cock\s?sucker(s|ing)?|\bn(i|1)g(\b|g?(a|er)?(s|z)?)\b|mudslime?s?|kikes?|\bspi(c|k)s?\b|\bchinks?|gooks?|bitch(es|ing|y)?|whor(es?|ing)|\btr(a|@)nn?(y|ies?)|\b(b|re|r)tard(ed)?s?)" ) . case_insensitive ( true ) . build ( ) . unwrap ( ) ;
static ref USERNAME_MATCHES_REGEX : Regex = Regex ::new ( r"/u/[a-zA-Z][0-9a-zA-Z_]*" ) . unwrap ( ) ;
// TODO keep this old one, it didn't work with port well tho
// static ref MENTIONS_REGEX: Regex = Regex::new(r"@(?P<name>[\w.]+)@(?P<domain>[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)"). unwrap( );
static ref MENTIONS_REGEX : Regex = Regex ::new ( r"@(?P<name>[\w.]+)@(?P<domain>[a-zA-Z0-9._:-]+)" ) . unwrap ( ) ;
static ref VALID_USERNAME_REGEX : Regex = Regex ::new ( r"^[a-zA-Z0-9_]{3,20}$" ) . unwrap ( ) ;
static ref VALID_COMMUNITY_NAME_REGEX : Regex = Regex ::new ( r"^[a-z0-9_]{3,20}$" ) . unwrap ( ) ;
static ref VALID_POST_TITLE_REGEX : Regex = Regex ::new ( r".*\S.*" ) . unwrap ( ) ;
static ref EMAIL_REGEX : Regex = Regex ::new ( r"^[a-zA-Z0-9.!#$%&’ *+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$" ).expect("compile regex" ) ;
static ref SLUR_REGEX : Regex = RegexBuilder ::new ( r"(fag(g|got|tard)?\b|cock\s?sucker(s|ing)?|\bn(i|1)g(\b|g?(a|er)?(s|z)?)\b|mudslime?s?|kikes?|\bspi(c|k)s?\b|\bchinks?|gooks?|bitch(es|ing|y)?|whor(es?|ing)|\btr(a|@)nn?(y|ies?)|\b(b|re|r)tard(ed)?s?)" ).case_insensitive(true).build().expect("compile regex" ) ;
static ref USERNAME_MATCHES_REGEX : Regex = Regex ::new ( r"/u/[a-zA-Z][0-9a-zA-Z_]*" ).expect("compile regex" ) ;
// TODO keep this old one, it didn't work with port well tho
// static ref MENTIONS_REGEX: Regex = Regex::new(r"@(?P<name>[\w.]+)@(?P<domain>[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)"). expect("compile regex" );
static ref MENTIONS_REGEX : Regex = Regex ::new ( r"@(?P<name>[\w.]+)@(?P<domain>[a-zA-Z0-9._:-]+)" ).expect("compile regex" ) ;
static ref VALID_USERNAME_REGEX : Regex = Regex ::new ( r"^[a-zA-Z0-9_]{3,20}$" ).expect("compile regex" ) ;
static ref VALID_COMMUNITY_NAME_REGEX : Regex = Regex ::new ( r"^[a-z0-9_]{3,20}$" ).expect("compile regex" ) ;
static ref VALID_POST_TITLE_REGEX : Regex = Regex ::new ( r".*\S.*" ).expect("compile regex" ) ;
}
pub fn naive_from_unix ( time : i64 ) -> NaiveDateTime {