lemmy_rate_limit doesnt depend on lemmy_api_structs anymore

This commit is contained in:
Felix Ableitner 2020-09-03 18:05:23 +02:00
parent 0a86c0934c
commit 2dd453afdf
14 changed files with 41 additions and 33 deletions

3
server/Cargo.lock generated vendored
View file

@ -1800,7 +1800,6 @@ version = "0.1.0"
dependencies = [ dependencies = [
"lemmy_db", "lemmy_db",
"serde 1.0.114", "serde 1.0.114",
"thiserror",
] ]
[[package]] [[package]]
@ -1827,7 +1826,6 @@ version = "0.1.0"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"futures", "futures",
"lemmy_api_structs",
"lemmy_utils", "lemmy_utils",
"log", "log",
"strum", "strum",
@ -1904,6 +1902,7 @@ dependencies = [
"regex", "regex",
"serde 1.0.114", "serde 1.0.114",
"serde_json", "serde_json",
"thiserror",
"url", "url",
] ]

View file

@ -11,4 +11,3 @@ path = "src/lib.rs"
[dependencies] [dependencies]
lemmy_db = { path = "../lemmy_db" } lemmy_db = { path = "../lemmy_db" }
serde = { version = "1.0.105", features = ["derive"] } serde = { version = "1.0.105", features = ["derive"] }
thiserror = "1.0.20"

View file

@ -1,24 +1,7 @@
extern crate serde; extern crate serde;
extern crate thiserror;
pub mod comment; pub mod comment;
pub mod community; pub mod community;
pub mod post; pub mod post;
pub mod site; pub mod site;
pub mod user; pub mod user;
use thiserror::Error;
#[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(),
}
}
}

View file

@ -10,7 +10,6 @@ path = "src/lib.rs"
[dependencies] [dependencies]
lemmy_utils = { path = "../lemmy_utils" } lemmy_utils = { path = "../lemmy_utils" }
lemmy_api_structs = { path = "../lemmy_api_structs" }
tokio = "0.2.21" tokio = "0.2.21"
strum = "0.18.0" strum = "0.18.0"
strum_macros = "0.18.0" strum_macros = "0.18.0"

View file

@ -1,5 +1,4 @@
use lemmy_api_structs::APIError; use lemmy_utils::{APIError, IPAddr, LemmyError};
use lemmy_utils::{IPAddr, LemmyError};
use log::debug; use log::debug;
use std::{collections::HashMap, time::SystemTime}; use std::{collections::HashMap, time::SystemTime};
use strum::IntoEnumIterator; use strum::IntoEnumIterator;

View file

@ -20,6 +20,7 @@ itertools = "0.9.0"
rand = "0.7.3" rand = "0.7.3"
serde = { version = "1.0.105", features = ["derive"] } serde = { version = "1.0.105", features = ["derive"] }
serde_json = { version = "1.0.52", features = ["preserve_order"]} serde_json = { version = "1.0.52", features = ["preserve_order"]}
thiserror = "1.0.20"
comrak = "0.7" comrak = "0.7"
lazy_static = "1.3.0" lazy_static = "1.3.0"
openssl = "0.10" openssl = "0.10"

View file

@ -9,6 +9,7 @@ extern crate openssl;
extern crate rand; extern crate rand;
extern crate regex; extern crate regex;
extern crate serde_json; extern crate serde_json;
extern crate thiserror;
extern crate url; extern crate url;
pub mod settings; pub mod settings;
@ -32,6 +33,7 @@ use openssl::{pkey::PKey, rsa::Rsa};
use rand::{distributions::Alphanumeric, thread_rng, Rng}; use rand::{distributions::Alphanumeric, thread_rng, Rng};
use regex::{Regex, RegexBuilder}; use regex::{Regex, RegexBuilder};
use std::io::{Error, ErrorKind}; use std::io::{Error, ErrorKind};
use thiserror::Error;
use url::Url; use url::Url;
pub type ConnectionId = usize; pub type ConnectionId = usize;
@ -52,6 +54,20 @@ macro_rules! location_info {
}; };
} }
#[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)] #[derive(Debug)]
pub struct LemmyError { pub struct LemmyError {
inner: anyhow::Error, inner: anyhow::Error,

View file

@ -17,7 +17,7 @@ use crate::{
LemmyContext, LemmyContext,
}; };
use actix_web::web::Data; use actix_web::web::Data;
use lemmy_api_structs::{comment::*, APIError}; use lemmy_api_structs::comment::*;
use lemmy_db::{ use lemmy_db::{
comment::*, comment::*,
comment_view::*, comment_view::*,
@ -38,6 +38,7 @@ use lemmy_utils::{
scrape_text_for_mentions, scrape_text_for_mentions,
send_email, send_email,
settings::Settings, settings::Settings,
APIError,
ConnectionId, ConnectionId,
EndpointType, EndpointType,
LemmyError, LemmyError,

View file

@ -18,7 +18,7 @@ use crate::{
}; };
use actix_web::web::Data; use actix_web::web::Data;
use anyhow::Context; use anyhow::Context;
use lemmy_api_structs::{community::*, APIError}; use lemmy_api_structs::community::*;
use lemmy_db::{ use lemmy_db::{
comment::Comment, comment::Comment,
comment_view::CommentQueryBuilder, comment_view::CommentQueryBuilder,
@ -42,6 +42,7 @@ use lemmy_utils::{
location_info, location_info,
make_apub_endpoint, make_apub_endpoint,
naive_from_unix, naive_from_unix,
APIError,
ConnectionId, ConnectionId,
EndpointType, EndpointType,
LemmyError, LemmyError,

View file

@ -1,6 +1,5 @@
use crate::{api::claims::Claims, blocking, DbPool, LemmyContext}; use crate::{api::claims::Claims, blocking, DbPool, LemmyContext};
use actix_web::web::Data; use actix_web::web::Data;
use lemmy_api_structs::APIError;
use lemmy_db::{ use lemmy_db::{
community::Community, community::Community,
community_view::CommunityUserBanView, community_view::CommunityUserBanView,
@ -8,7 +7,7 @@ use lemmy_db::{
user::User_, user::User_,
Crud, Crud,
}; };
use lemmy_utils::{slur_check, slurs_vec_to_str, ConnectionId, LemmyError}; use lemmy_utils::{slur_check, slurs_vec_to_str, APIError, ConnectionId, LemmyError};
pub mod claims; pub mod claims;
pub mod comment; pub mod comment;

View file

@ -18,7 +18,7 @@ use crate::{
LemmyContext, LemmyContext,
}; };
use actix_web::web::Data; use actix_web::web::Data;
use lemmy_api_structs::{post::*, APIError}; use lemmy_api_structs::post::*;
use lemmy_db::{ use lemmy_db::{
comment_view::*, comment_view::*,
community_view::*, community_view::*,
@ -36,6 +36,7 @@ use lemmy_db::{
use lemmy_utils::{ use lemmy_utils::{
is_valid_post_title, is_valid_post_title,
make_apub_endpoint, make_apub_endpoint,
APIError,
ConnectionId, ConnectionId,
EndpointType, EndpointType,
LemmyError, LemmyError,

View file

@ -18,7 +18,7 @@ use crate::{
}; };
use actix_web::web::Data; use actix_web::web::Data;
use anyhow::Context; use anyhow::Context;
use lemmy_api_structs::{site::*, user::Register, APIError}; use lemmy_api_structs::{site::*, user::Register};
use lemmy_db::{ use lemmy_db::{
category::*, category::*,
comment_view::*, comment_view::*,
@ -35,7 +35,7 @@ use lemmy_db::{
SearchType, SearchType,
SortType, SortType,
}; };
use lemmy_utils::{location_info, settings::Settings, ConnectionId, LemmyError}; use lemmy_utils::{location_info, settings::Settings, APIError, ConnectionId, LemmyError};
use log::{debug, info}; use log::{debug, info};
use std::str::FromStr; use std::str::FromStr;

View file

@ -14,7 +14,7 @@ use anyhow::Context;
use bcrypt::verify; use bcrypt::verify;
use captcha::{gen, Difficulty}; use captcha::{gen, Difficulty};
use chrono::Duration; use chrono::Duration;
use lemmy_api_structs::{user::*, APIError}; use lemmy_api_structs::user::*;
use lemmy_db::{ use lemmy_db::{
comment::*, comment::*,
comment_view::*, comment_view::*,
@ -51,6 +51,7 @@ use lemmy_utils::{
remove_slurs, remove_slurs,
send_email, send_email,
settings::Settings, settings::Settings,
APIError,
ConnectionId, ConnectionId,
EndpointType, EndpointType,
LemmyError, LemmyError,

View file

@ -13,9 +13,18 @@ use diesel::{
r2d2::{ConnectionManager, Pool}, r2d2::{ConnectionManager, Pool},
PgConnection, PgConnection,
}; };
use lemmy_api_structs::{comment::*, community::*, post::*, site::*, user::*, APIError}; use lemmy_api_structs::{comment::*, community::*, post::*, site::*, user::*};
use lemmy_rate_limit::RateLimit; use lemmy_rate_limit::RateLimit;
use lemmy_utils::{location_info, CommunityId, ConnectionId, IPAddr, LemmyError, PostId, UserId}; use lemmy_utils::{
location_info,
APIError,
CommunityId,
ConnectionId,
IPAddr,
LemmyError,
PostId,
UserId,
};
use rand::rngs::ThreadRng; use rand::rngs::ThreadRng;
use reqwest::Client; use reqwest::Client;
use serde::Serialize; use serde::Serialize;