mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-05-05 11:38:44 +00:00
5c6258390c
* Adding a way to GetComments for a community given its name only. * Adding getcomments to api docs. * A first pass at locally working isomorphic integration. * Testing out cargo-husky. * Testing a fail hook. * Revert "Testing a fail hook." This reverts commit0941cf1736
. * Moving server to top level, now that UI is gone. * Running cargo fmt using old way. * Adding nginx, fixing up docker-compose files, fixing docs. * Trying to re-add API tests. * Fixing prod dockerfile. * Redoing nightly fmt * Trying to fix private message api test. * Adding CommunityJoin, PostJoin instead of joins from GetComments, etc. - Fixes #1122 * Fixing fmt. * Fixing up docs. * Removing translations. * Adding apps / clients to readme. * Fixing main image. * Using new lemmy-isomorphic-ui with better javascript disabled. * Try to fix image uploads in federation test * Revert "Try to fix image uploads in federation test" This reverts commita2ddf2a90b
. * Fix post url federation * Adding some more tests, some still broken. * Don't need gitattributes anymore. * Update local federation test setup * Fixing tests. * Fixing travis build. * Fixing travis build, again. * Changing lemmy-isomorphic-ui to lemmy-ui * Error in travis build again. Co-authored-by: Felix Ableitner <me@nutomic.com>
94 lines
1.8 KiB
Rust
94 lines
1.8 KiB
Rust
#[macro_use]
|
|
extern crate lazy_static;
|
|
extern crate actix_web;
|
|
extern crate anyhow;
|
|
extern crate comrak;
|
|
extern crate lettre;
|
|
extern crate lettre_email;
|
|
extern crate openssl;
|
|
extern crate rand;
|
|
extern crate regex;
|
|
extern crate serde_json;
|
|
extern crate thiserror;
|
|
extern crate url;
|
|
|
|
pub mod apub;
|
|
pub mod email;
|
|
pub mod settings;
|
|
#[cfg(test)]
|
|
mod test;
|
|
pub mod utils;
|
|
|
|
use crate::settings::Settings;
|
|
use regex::Regex;
|
|
use thiserror::Error;
|
|
|
|
pub type ConnectionId = usize;
|
|
pub type PostId = i32;
|
|
pub type CommunityId = i32;
|
|
pub type UserId = i32;
|
|
pub type IPAddr = String;
|
|
|
|
#[macro_export]
|
|
macro_rules! location_info {
|
|
() => {
|
|
format!(
|
|
"None value at {}:{}, column {}",
|
|
file!(),
|
|
line!(),
|
|
column!()
|
|
)
|
|
};
|
|
}
|
|
|
|
#[derive(Debug, Error)]
|
|
#[error("{{\"error\":\"{message}\"}}")]
|
|
pub struct APIError {
|
|
pub message: String,
|
|
}
|
|
|
|
impl APIError {
|
|
pub fn err(msg: &str) -> Self {
|
|
APIError {
|
|
message: msg.to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct LemmyError {
|
|
inner: anyhow::Error,
|
|
}
|
|
|
|
impl<T> From<T> for LemmyError
|
|
where
|
|
T: Into<anyhow::Error>,
|
|
{
|
|
fn from(t: T) -> Self {
|
|
LemmyError { inner: t.into() }
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for LemmyError {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
self.inner.fmt(f)
|
|
}
|
|
}
|
|
|
|
impl actix_web::error::ResponseError for LemmyError {}
|
|
|
|
lazy_static! {
|
|
pub static ref WEBFINGER_COMMUNITY_REGEX: Regex = Regex::new(&format!(
|
|
"^group:([a-z0-9_]{{3, 20}})@{}$",
|
|
Settings::get().hostname
|
|
))
|
|
.unwrap();
|
|
pub static ref WEBFINGER_USER_REGEX: Regex = Regex::new(&format!(
|
|
"^acct:([a-z0-9_]{{3, 20}})@{}$",
|
|
Settings::get().hostname
|
|
))
|
|
.unwrap();
|
|
pub static ref CACHE_CONTROL_REGEX: Regex =
|
|
Regex::new("^((text|image)/.+|application/javascript)$").unwrap();
|
|
}
|