2 extern crate lazy_static;
3 extern crate actix_web;
7 extern crate lettre_email;
11 extern crate serde_json;
12 extern crate thiserror;
22 use crate::settings::Settings;
26 pub type ConnectionId = usize;
27 pub type PostId = i32;
28 pub type CommunityId = i32;
29 pub type UserId = i32;
30 pub type IPAddr = String;
33 macro_rules! location_info {
36 "None value at {}:{}, column {}",
44 #[derive(Debug, Error)]
45 #[error("{{\"error\":\"{message}\"}}")]
51 pub fn err(msg: &str) -> Self {
53 message: msg.to_string(),
59 pub struct LemmyError {
63 impl<T> From<T> for LemmyError
65 T: Into<anyhow::Error>,
67 fn from(t: T) -> Self {
68 LemmyError { inner: t.into() }
72 impl std::fmt::Display for LemmyError {
73 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
78 impl actix_web::error::ResponseError for LemmyError {}
81 pub static ref WEBFINGER_COMMUNITY_REGEX: Regex = Regex::new(&format!(
82 "^group:([a-z0-9_]{{3, 20}})@{}$",
83 Settings::get().hostname
86 pub static ref WEBFINGER_USER_REGEX: Regex = Regex::new(&format!(
87 "^acct:([a-z0-9_]{{3, 20}})@{}$",
88 Settings::get().hostname
91 pub static ref CACHE_CONTROL_REGEX: Regex =
92 Regex::new("^((text|image)/.+|application/javascript)$").unwrap();