2 extern crate lazy_static;
4 extern crate strum_macros;
15 use crate::settings::Settings;
19 pub type ConnectionId = usize;
20 pub type PostId = i32;
21 pub type CommunityId = i32;
22 pub type UserId = i32;
23 pub type IPAddr = String;
26 macro_rules! location_info {
29 "None value at {}:{}, column {}",
37 #[derive(Debug, Error)]
38 #[error("{{\"error\":\"{message}\"}}")]
44 pub fn err(msg: &str) -> Self {
46 message: msg.to_string(),
52 pub struct LemmyError {
53 pub inner: anyhow::Error,
56 impl<T> From<T> for LemmyError
58 T: Into<anyhow::Error>,
60 fn from(t: T) -> Self {
61 LemmyError { inner: t.into() }
65 impl std::fmt::Display for LemmyError {
66 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
71 impl actix_web::error::ResponseError for LemmyError {}
74 pub static ref WEBFINGER_COMMUNITY_REGEX: Regex = Regex::new(&format!(
75 "^group:([a-z0-9_]{{3, 20}})@{}$",
76 Settings::get().hostname
79 pub static ref WEBFINGER_USER_REGEX: Regex = Regex::new(&format!(
80 "^acct:([a-z0-9_]{{3, 20}})@{}$",
81 Settings::get().hostname