lemmy_rate_limit doesnt depend on lemmy_api_structs anymore
This commit is contained in:
parent
0a86c0934c
commit
2dd453afdf
14 changed files with 41 additions and 33 deletions
3
server/Cargo.lock
generated
vendored
3
server/Cargo.lock
generated
vendored
|
@ -1800,7 +1800,6 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"lemmy_db",
|
||||
"serde 1.0.114",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1827,7 +1826,6 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"actix-web",
|
||||
"futures",
|
||||
"lemmy_api_structs",
|
||||
"lemmy_utils",
|
||||
"log",
|
||||
"strum",
|
||||
|
@ -1904,6 +1902,7 @@ dependencies = [
|
|||
"regex",
|
||||
"serde 1.0.114",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"url",
|
||||
]
|
||||
|
||||
|
|
1
server/lemmy_api_structs/Cargo.toml
vendored
1
server/lemmy_api_structs/Cargo.toml
vendored
|
@ -11,4 +11,3 @@ path = "src/lib.rs"
|
|||
[dependencies]
|
||||
lemmy_db = { path = "../lemmy_db" }
|
||||
serde = { version = "1.0.105", features = ["derive"] }
|
||||
thiserror = "1.0.20"
|
||||
|
|
|
@ -1,24 +1,7 @@
|
|||
extern crate serde;
|
||||
extern crate thiserror;
|
||||
|
||||
pub mod comment;
|
||||
pub mod community;
|
||||
pub mod post;
|
||||
pub mod site;
|
||||
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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
1
server/lemmy_rate_limit/Cargo.toml
vendored
1
server/lemmy_rate_limit/Cargo.toml
vendored
|
@ -10,7 +10,6 @@ path = "src/lib.rs"
|
|||
|
||||
[dependencies]
|
||||
lemmy_utils = { path = "../lemmy_utils" }
|
||||
lemmy_api_structs = { path = "../lemmy_api_structs" }
|
||||
tokio = "0.2.21"
|
||||
strum = "0.18.0"
|
||||
strum_macros = "0.18.0"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use lemmy_api_structs::APIError;
|
||||
use lemmy_utils::{IPAddr, LemmyError};
|
||||
use lemmy_utils::{APIError, IPAddr, LemmyError};
|
||||
use log::debug;
|
||||
use std::{collections::HashMap, time::SystemTime};
|
||||
use strum::IntoEnumIterator;
|
||||
|
|
1
server/lemmy_utils/Cargo.toml
vendored
1
server/lemmy_utils/Cargo.toml
vendored
|
@ -20,6 +20,7 @@ itertools = "0.9.0"
|
|||
rand = "0.7.3"
|
||||
serde = { version = "1.0.105", features = ["derive"] }
|
||||
serde_json = { version = "1.0.52", features = ["preserve_order"]}
|
||||
thiserror = "1.0.20"
|
||||
comrak = "0.7"
|
||||
lazy_static = "1.3.0"
|
||||
openssl = "0.10"
|
||||
|
|
|
@ -9,6 +9,7 @@ extern crate openssl;
|
|||
extern crate rand;
|
||||
extern crate regex;
|
||||
extern crate serde_json;
|
||||
extern crate thiserror;
|
||||
extern crate url;
|
||||
|
||||
pub mod settings;
|
||||
|
@ -32,6 +33,7 @@ use openssl::{pkey::PKey, rsa::Rsa};
|
|||
use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
||||
use regex::{Regex, RegexBuilder};
|
||||
use std::io::{Error, ErrorKind};
|
||||
use thiserror::Error;
|
||||
use url::Url;
|
||||
|
||||
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)]
|
||||
pub struct LemmyError {
|
||||
inner: anyhow::Error,
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::{
|
|||
LemmyContext,
|
||||
};
|
||||
use actix_web::web::Data;
|
||||
use lemmy_api_structs::{comment::*, APIError};
|
||||
use lemmy_api_structs::comment::*;
|
||||
use lemmy_db::{
|
||||
comment::*,
|
||||
comment_view::*,
|
||||
|
@ -38,6 +38,7 @@ use lemmy_utils::{
|
|||
scrape_text_for_mentions,
|
||||
send_email,
|
||||
settings::Settings,
|
||||
APIError,
|
||||
ConnectionId,
|
||||
EndpointType,
|
||||
LemmyError,
|
||||
|
|
|
@ -18,7 +18,7 @@ use crate::{
|
|||
};
|
||||
use actix_web::web::Data;
|
||||
use anyhow::Context;
|
||||
use lemmy_api_structs::{community::*, APIError};
|
||||
use lemmy_api_structs::community::*;
|
||||
use lemmy_db::{
|
||||
comment::Comment,
|
||||
comment_view::CommentQueryBuilder,
|
||||
|
@ -42,6 +42,7 @@ use lemmy_utils::{
|
|||
location_info,
|
||||
make_apub_endpoint,
|
||||
naive_from_unix,
|
||||
APIError,
|
||||
ConnectionId,
|
||||
EndpointType,
|
||||
LemmyError,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{api::claims::Claims, blocking, DbPool, LemmyContext};
|
||||
use actix_web::web::Data;
|
||||
use lemmy_api_structs::APIError;
|
||||
use lemmy_db::{
|
||||
community::Community,
|
||||
community_view::CommunityUserBanView,
|
||||
|
@ -8,7 +7,7 @@ use lemmy_db::{
|
|||
user::User_,
|
||||
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 comment;
|
||||
|
|
|
@ -18,7 +18,7 @@ use crate::{
|
|||
LemmyContext,
|
||||
};
|
||||
use actix_web::web::Data;
|
||||
use lemmy_api_structs::{post::*, APIError};
|
||||
use lemmy_api_structs::post::*;
|
||||
use lemmy_db::{
|
||||
comment_view::*,
|
||||
community_view::*,
|
||||
|
@ -36,6 +36,7 @@ use lemmy_db::{
|
|||
use lemmy_utils::{
|
||||
is_valid_post_title,
|
||||
make_apub_endpoint,
|
||||
APIError,
|
||||
ConnectionId,
|
||||
EndpointType,
|
||||
LemmyError,
|
||||
|
|
|
@ -18,7 +18,7 @@ use crate::{
|
|||
};
|
||||
use actix_web::web::Data;
|
||||
use anyhow::Context;
|
||||
use lemmy_api_structs::{site::*, user::Register, APIError};
|
||||
use lemmy_api_structs::{site::*, user::Register};
|
||||
use lemmy_db::{
|
||||
category::*,
|
||||
comment_view::*,
|
||||
|
@ -35,7 +35,7 @@ use lemmy_db::{
|
|||
SearchType,
|
||||
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 std::str::FromStr;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use anyhow::Context;
|
|||
use bcrypt::verify;
|
||||
use captcha::{gen, Difficulty};
|
||||
use chrono::Duration;
|
||||
use lemmy_api_structs::{user::*, APIError};
|
||||
use lemmy_api_structs::user::*;
|
||||
use lemmy_db::{
|
||||
comment::*,
|
||||
comment_view::*,
|
||||
|
@ -51,6 +51,7 @@ use lemmy_utils::{
|
|||
remove_slurs,
|
||||
send_email,
|
||||
settings::Settings,
|
||||
APIError,
|
||||
ConnectionId,
|
||||
EndpointType,
|
||||
LemmyError,
|
||||
|
|
|
@ -13,9 +13,18 @@ use diesel::{
|
|||
r2d2::{ConnectionManager, Pool},
|
||||
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_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 reqwest::Client;
|
||||
use serde::Serialize;
|
||||
|
|
Loading…
Reference in a new issue