mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-16 09:24:00 +00:00
Move routes into separate crate to speed up compilation
This commit is contained in:
parent
ce00677880
commit
999d9f4d6c
25 changed files with 106 additions and 151 deletions
141
Cargo.lock
generated
141
Cargo.lock
generated
|
@ -88,26 +88,6 @@ dependencies = [
|
||||||
"webpki",
|
"webpki",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "actix-files"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c51e8a9146c12fce92a6e4c24b8c4d9b05268130bfd8d61bc587e822c32ce689"
|
|
||||||
dependencies = [
|
|
||||||
"actix-service",
|
|
||||||
"actix-web",
|
|
||||||
"bitflags",
|
|
||||||
"bytes 0.5.6",
|
|
||||||
"derive_more",
|
|
||||||
"futures-core",
|
|
||||||
"futures-util",
|
|
||||||
"log",
|
|
||||||
"mime",
|
|
||||||
"mime_guess",
|
|
||||||
"percent-encoding",
|
|
||||||
"v_htmlescape",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix-http"
|
name = "actix-http"
|
||||||
version = "2.2.0"
|
version = "2.2.0"
|
||||||
|
@ -662,15 +642,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "buf-min"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fa17aa1cf56bdd6bb30518767d00e58019d326f3f05d8c3e0730b549d332ea83"
|
|
||||||
dependencies = [
|
|
||||||
"bytes 0.5.6",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
version = "3.6.0"
|
version = "3.6.0"
|
||||||
|
@ -836,7 +807,7 @@ checksum = "784ad0fbab4f3e9cef09f20e0aea6000ae08d2cb98ac4c0abc53df18803d702f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"time 0.2.25",
|
"time 0.2.25",
|
||||||
"version_check 0.9.2",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1050,17 +1021,6 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "diesel_json"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2812f0f63b6d3508fb7bfdb872c2dc2321ba938f5e0f4cb9751ec899e8b297c9"
|
|
||||||
dependencies = [
|
|
||||||
"diesel",
|
|
||||||
"serde 1.0.123",
|
|
||||||
"serde_json",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "diesel_migrations"
|
name = "diesel_migrations"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
|
@ -1356,7 +1316,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
|
checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"typenum",
|
"typenum",
|
||||||
"version_check 0.9.2",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1771,7 +1731,6 @@ dependencies = [
|
||||||
"http",
|
"http",
|
||||||
"http-signature-normalization-actix",
|
"http-signature-normalization-actix",
|
||||||
"itertools",
|
"itertools",
|
||||||
"jsonwebtoken",
|
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lemmy_apub",
|
"lemmy_apub",
|
||||||
"lemmy_db_queries",
|
"lemmy_db_queries",
|
||||||
|
@ -1851,7 +1810,6 @@ dependencies = [
|
||||||
"bcrypt",
|
"bcrypt",
|
||||||
"chrono",
|
"chrono",
|
||||||
"diesel",
|
"diesel",
|
||||||
"diesel_json",
|
|
||||||
"diesel_migrations",
|
"diesel_migrations",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lemmy_db_schema",
|
"lemmy_db_schema",
|
||||||
|
@ -1910,18 +1868,42 @@ dependencies = [
|
||||||
"serde 1.0.123",
|
"serde 1.0.123",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lemmy_routes"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"actix",
|
||||||
|
"actix-web",
|
||||||
|
"actix-web-actors",
|
||||||
|
"anyhow",
|
||||||
|
"awc",
|
||||||
|
"chrono",
|
||||||
|
"diesel",
|
||||||
|
"lazy_static",
|
||||||
|
"lemmy_db_queries",
|
||||||
|
"lemmy_db_schema",
|
||||||
|
"lemmy_db_views",
|
||||||
|
"lemmy_db_views_actor",
|
||||||
|
"lemmy_structs",
|
||||||
|
"lemmy_utils",
|
||||||
|
"lemmy_websocket",
|
||||||
|
"log",
|
||||||
|
"rss",
|
||||||
|
"serde 1.0.123",
|
||||||
|
"sha2",
|
||||||
|
"strum",
|
||||||
|
"url",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lemmy_server"
|
name = "lemmy_server"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"activitystreams",
|
"activitystreams",
|
||||||
"actix",
|
"actix",
|
||||||
"actix-files",
|
|
||||||
"actix-rt",
|
"actix-rt",
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"actix-web-actors",
|
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"awc",
|
|
||||||
"cargo-husky",
|
"cargo-husky",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clokwerk",
|
"clokwerk",
|
||||||
|
@ -1929,7 +1911,6 @@ dependencies = [
|
||||||
"diesel_migrations",
|
"diesel_migrations",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"http-signature-normalization-actix",
|
"http-signature-normalization-actix",
|
||||||
"lazy_static",
|
|
||||||
"lemmy_api",
|
"lemmy_api",
|
||||||
"lemmy_apub",
|
"lemmy_apub",
|
||||||
"lemmy_db_queries",
|
"lemmy_db_queries",
|
||||||
|
@ -1937,16 +1918,15 @@ dependencies = [
|
||||||
"lemmy_db_views",
|
"lemmy_db_views",
|
||||||
"lemmy_db_views_actor",
|
"lemmy_db_views_actor",
|
||||||
"lemmy_db_views_moderator",
|
"lemmy_db_views_moderator",
|
||||||
|
"lemmy_routes",
|
||||||
"lemmy_structs",
|
"lemmy_structs",
|
||||||
"lemmy_utils",
|
"lemmy_utils",
|
||||||
"lemmy_websocket",
|
"lemmy_websocket",
|
||||||
"log",
|
"log",
|
||||||
"openssl",
|
"openssl",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rss",
|
|
||||||
"serde 1.0.123",
|
"serde 1.0.123",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
|
||||||
"strum",
|
"strum",
|
||||||
"tokio 0.3.7",
|
"tokio 0.3.7",
|
||||||
"url",
|
"url",
|
||||||
|
@ -1985,6 +1965,7 @@ dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"http",
|
"http",
|
||||||
"itertools",
|
"itertools",
|
||||||
|
"jsonwebtoken",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lettre",
|
"lettre",
|
||||||
"log",
|
"log",
|
||||||
|
@ -2007,6 +1988,8 @@ name = "lemmy_websocket"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix",
|
"actix",
|
||||||
|
"actix-web",
|
||||||
|
"actix-web-actors",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"background-jobs",
|
"background-jobs",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
@ -2288,16 +2271,6 @@ dependencies = [
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nom"
|
|
||||||
version = "4.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
"version_check 0.1.5",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nom"
|
name = "nom"
|
||||||
version = "5.1.2"
|
version = "5.1.2"
|
||||||
|
@ -2306,7 +2279,7 @@ checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lexical-core",
|
"lexical-core",
|
||||||
"memchr",
|
"memchr",
|
||||||
"version_check 0.9.2",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2317,7 +2290,7 @@ checksum = "ab6f70b46d6325aa300f1c7bb3d470127dfc27806d8ea6bf294ee0ce643ce2b1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitvec",
|
"bitvec",
|
||||||
"memchr",
|
"memchr",
|
||||||
"version_check 0.9.2",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3212,7 +3185,7 @@ version = "0.2.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c66a8cff4fa24853fdf6b51f75c6d7f8206d7c75cab4e467bcd7f25c2b1febe0"
|
checksum = "c66a8cff4fa24853fdf6b51f75c6d7f8206d7c75cab4e467bcd7f25c2b1febe0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"version_check 0.9.2",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3405,7 +3378,7 @@ dependencies = [
|
||||||
"standback",
|
"standback",
|
||||||
"stdweb",
|
"stdweb",
|
||||||
"time-macros",
|
"time-macros",
|
||||||
"version_check 0.9.2",
|
"version_check",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3638,7 +3611,7 @@ version = "2.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
|
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"version_check 0.9.2",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3706,50 +3679,12 @@ dependencies = [
|
||||||
"serde 1.0.123",
|
"serde 1.0.123",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "v_escape"
|
|
||||||
version = "0.15.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f3e0ab5fab1db278a9413d2ea794cb66f471f898c5b020c3c394f6447625d9d4"
|
|
||||||
dependencies = [
|
|
||||||
"buf-min",
|
|
||||||
"v_escape_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "v_escape_derive"
|
|
||||||
version = "0.8.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c860ad1273f4eee7006cee05db20c9e60e5d24cba024a32e1094aa8e574f3668"
|
|
||||||
dependencies = [
|
|
||||||
"nom 4.2.3",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "v_htmlescape"
|
|
||||||
version = "0.12.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1f9a8af610ad6f7fc9989c9d2590d9764bc61f294884e9ee93baa58795174572"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 1.0.0",
|
|
||||||
"v_escape",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vcpkg"
|
name = "vcpkg"
|
||||||
version = "0.2.11"
|
version = "0.2.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb"
|
checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "version_check"
|
|
||||||
version = "0.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.2"
|
version = "0.9.2"
|
||||||
|
|
|
@ -18,6 +18,7 @@ members = [
|
||||||
"crates/db_views_actor",
|
"crates/db_views_actor",
|
||||||
"crates/structs",
|
"crates/structs",
|
||||||
"crates/websocket",
|
"crates/websocket",
|
||||||
|
"crates/routes"
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -31,25 +32,20 @@ lemmy_db_views_moderator = { path = "./crates/db_views_moderator" }
|
||||||
lemmy_db_views_actor = { path = "./crates/db_views_actor" }
|
lemmy_db_views_actor = { path = "./crates/db_views_actor" }
|
||||||
lemmy_structs = { path = "./crates/structs" }
|
lemmy_structs = { path = "./crates/structs" }
|
||||||
lemmy_websocket = { path = "./crates/websocket" }
|
lemmy_websocket = { path = "./crates/websocket" }
|
||||||
|
lemmy_routes = { path = "./crates/routes" }
|
||||||
diesel = "1.4.5"
|
diesel = "1.4.5"
|
||||||
diesel_migrations = "1.4.0"
|
diesel_migrations = "1.4.0"
|
||||||
chrono = { version = "0.4.19", features = ["serde"] }
|
chrono = { version = "0.4.19", features = ["serde"] }
|
||||||
serde = { version = "1.0.123", features = ["derive"] }
|
serde = { version = "1.0.123", features = ["derive"] }
|
||||||
actix = "0.10.0"
|
actix = "0.10.0"
|
||||||
actix-web = { version = "3.3.2", default-features = false, features = ["rustls"] }
|
actix-web = { version = "3.3.2", default-features = false, features = ["rustls"] }
|
||||||
actix-files = { version = "0.5.0", default-features = false }
|
|
||||||
actix-web-actors = { version = "3.0.0", default-features = false }
|
|
||||||
awc = { version = "2.0.3", default-features = false }
|
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
env_logger = "0.8.2"
|
env_logger = "0.8.2"
|
||||||
strum = "0.20.0"
|
strum = "0.20.0"
|
||||||
lazy_static = "1.4.0"
|
|
||||||
rss = "1.10.0"
|
|
||||||
url = { version = "2.2.0", features = ["serde"] }
|
url = { version = "2.2.0", features = ["serde"] }
|
||||||
openssl = "0.10.32"
|
openssl = "0.10.32"
|
||||||
http-signature-normalization-actix = { version = "0.4.1", default-features = false, features = ["sha-2"] }
|
http-signature-normalization-actix = { version = "0.4.1", default-features = false, features = ["sha-2"] }
|
||||||
tokio = "0.3.6"
|
tokio = "0.3.6"
|
||||||
sha2 = "0.9.3"
|
|
||||||
anyhow = "1.0.38"
|
anyhow = "1.0.38"
|
||||||
reqwest = { version = "0.10.10", features = ["json"] }
|
reqwest = { version = "0.10.10", features = ["json"] }
|
||||||
activitystreams = "0.7.0-alpha.10"
|
activitystreams = "0.7.0-alpha.10"
|
||||||
|
|
|
@ -31,7 +31,6 @@ log = "0.4.14"
|
||||||
rand = "0.8.3"
|
rand = "0.8.3"
|
||||||
strum = "0.20.0"
|
strum = "0.20.0"
|
||||||
strum_macros = "0.20.1"
|
strum_macros = "0.20.1"
|
||||||
jsonwebtoken = "7.2.0"
|
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
url = { version = "2.2.0", features = ["serde"] }
|
url = { version = "2.2.0", features = ["serde"] }
|
||||||
openssl = "0.10.32"
|
openssl = "0.10.32"
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use crate::claims::Claims;
|
|
||||||
use actix_web::{web, web::Data};
|
use actix_web::{web, web::Data};
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_queries::{
|
||||||
source::{
|
source::{
|
||||||
|
@ -20,19 +19,18 @@ use lemmy_db_views_actor::{
|
||||||
community_view::CommunityView,
|
community_view::CommunityView,
|
||||||
};
|
};
|
||||||
use lemmy_structs::{blocking, comment::*, community::*, post::*, site::*, user::*, websocket::*};
|
use lemmy_structs::{blocking, comment::*, community::*, post::*, site::*, user::*, websocket::*};
|
||||||
use lemmy_utils::{settings::Settings, APIError, ConnectionId, LemmyError};
|
use lemmy_utils::{claims::Claims, settings::Settings, APIError, ConnectionId, LemmyError};
|
||||||
use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperation};
|
use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperation};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
pub mod claims;
|
|
||||||
pub mod comment;
|
pub mod comment;
|
||||||
pub mod community;
|
pub mod community;
|
||||||
pub mod post;
|
pub mod post;
|
||||||
|
pub mod routes;
|
||||||
pub mod site;
|
pub mod site;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
pub mod version;
|
|
||||||
pub mod websocket;
|
pub mod websocket;
|
||||||
|
|
||||||
#[async_trait::async_trait(?Send)]
|
#[async_trait::async_trait(?Send)]
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
|
use crate::Perform;
|
||||||
use actix_web::{error::ErrorBadRequest, *};
|
use actix_web::{error::ErrorBadRequest, *};
|
||||||
use lemmy_api::Perform;
|
|
||||||
use lemmy_structs::{comment::*, community::*, post::*, site::*, user::*, websocket::*};
|
use lemmy_structs::{comment::*, community::*, post::*, site::*, user::*, websocket::*};
|
||||||
use lemmy_utils::rate_limit::RateLimit;
|
use lemmy_utils::rate_limit::RateLimit;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::{routes::chat_route, LemmyContext};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
||||||
cfg.service(
|
cfg.service(
|
||||||
web::scope("/api/v2")
|
web::scope("/api/v2")
|
||||||
// Websockets
|
// Websockets
|
||||||
.service(web::resource("/ws").to(super::websocket::chat_route))
|
.service(web::resource("/ws").to(chat_route))
|
||||||
// Site
|
// Site
|
||||||
.service(
|
.service(
|
||||||
web::scope("/site")
|
web::scope("/site")
|
|
@ -5,7 +5,6 @@ use crate::{
|
||||||
get_user_safe_settings_from_jwt,
|
get_user_safe_settings_from_jwt,
|
||||||
get_user_safe_settings_from_jwt_opt,
|
get_user_safe_settings_from_jwt_opt,
|
||||||
is_admin,
|
is_admin,
|
||||||
version,
|
|
||||||
Perform,
|
Perform,
|
||||||
};
|
};
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
|
@ -51,6 +50,7 @@ use lemmy_utils::{
|
||||||
location_info,
|
location_info,
|
||||||
settings::Settings,
|
settings::Settings,
|
||||||
utils::{check_slurs, check_slurs_opt},
|
utils::{check_slurs, check_slurs_opt},
|
||||||
|
version,
|
||||||
APIError,
|
APIError,
|
||||||
ConnectionId,
|
ConnectionId,
|
||||||
LemmyError,
|
LemmyError,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
captcha_espeak_wav_base64,
|
captcha_espeak_wav_base64,
|
||||||
check_optional_url,
|
check_optional_url,
|
||||||
claims::Claims,
|
|
||||||
collect_moderated_communities,
|
collect_moderated_communities,
|
||||||
get_user_from_jwt,
|
get_user_from_jwt,
|
||||||
get_user_from_jwt_opt,
|
get_user_from_jwt_opt,
|
||||||
|
@ -69,6 +68,7 @@ use lemmy_db_views_actor::{
|
||||||
use lemmy_structs::{blocking, send_email_to_user, user::*};
|
use lemmy_structs::{blocking, send_email_to_user, user::*};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
apub::generate_actor_keypair,
|
apub::generate_actor_keypair,
|
||||||
|
claims::Claims,
|
||||||
email::send_email,
|
email::send_email,
|
||||||
location_info,
|
location_info,
|
||||||
settings::Settings,
|
settings::Settings,
|
||||||
|
@ -121,7 +121,7 @@ impl Perform for Login {
|
||||||
|
|
||||||
// Return the jwt
|
// Return the jwt
|
||||||
Ok(LoginResponse {
|
Ok(LoginResponse {
|
||||||
jwt: Claims::jwt(user, Settings::get().hostname)?,
|
jwt: Claims::jwt(user.id, Settings::get().hostname)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ impl Perform for Register {
|
||||||
|
|
||||||
// Return the jwt
|
// Return the jwt
|
||||||
Ok(LoginResponse {
|
Ok(LoginResponse {
|
||||||
jwt: Claims::jwt(inserted_user, Settings::get().hostname)?,
|
jwt: Claims::jwt(inserted_user.id, Settings::get().hostname)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,7 @@ impl Perform for SaveUserSettings {
|
||||||
|
|
||||||
// Return the jwt
|
// Return the jwt
|
||||||
Ok(LoginResponse {
|
Ok(LoginResponse {
|
||||||
jwt: Claims::jwt(updated_user, Settings::get().hostname)?,
|
jwt: Claims::jwt(updated_user.id, Settings::get().hostname)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1007,7 +1007,7 @@ impl Perform for PasswordChange {
|
||||||
|
|
||||||
// Return the jwt
|
// Return the jwt
|
||||||
Ok(LoginResponse {
|
Ok(LoginResponse {
|
||||||
jwt: Claims::jwt(updated_user, Settings::get().hostname)?,
|
jwt: Claims::jwt(updated_user.id, Settings::get().hostname)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ pub mod fetcher;
|
||||||
pub mod http;
|
pub mod http;
|
||||||
pub mod inbox;
|
pub mod inbox;
|
||||||
pub mod objects;
|
pub mod objects;
|
||||||
|
pub mod routes;
|
||||||
|
|
||||||
use crate::extensions::{
|
use crate::extensions::{
|
||||||
group_extensions::GroupExtension,
|
group_extensions::GroupExtension,
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
use actix_web::*;
|
use crate::{
|
||||||
use http_signature_normalization_actix::digest::middleware::VerifyDigest;
|
|
||||||
use lemmy_apub::{
|
|
||||||
http::{
|
http::{
|
||||||
comment::get_apub_comment,
|
comment::get_apub_comment,
|
||||||
community::{
|
community::{
|
||||||
|
@ -16,6 +14,8 @@ use lemmy_apub::{
|
||||||
inbox::{community_inbox::community_inbox, shared_inbox::shared_inbox, user_inbox::user_inbox},
|
inbox::{community_inbox::community_inbox, shared_inbox::shared_inbox, user_inbox::user_inbox},
|
||||||
APUB_JSON_CONTENT_TYPE,
|
APUB_JSON_CONTENT_TYPE,
|
||||||
};
|
};
|
||||||
|
use actix_web::*;
|
||||||
|
use http_signature_normalization_actix::digest::middleware::VerifyDigest;
|
||||||
use lemmy_utils::settings::Settings;
|
use lemmy_utils::settings::Settings;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|
|
@ -23,4 +23,3 @@ url = { version = "2.2.0", features = ["serde"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
regex = "1.4.3"
|
regex = "1.4.3"
|
||||||
bcrypt = "0.9.0"
|
bcrypt = "0.9.0"
|
||||||
diesel_json = "0.1.1"
|
|
||||||
|
|
27
crates/routes/Cargo.toml
Normal file
27
crates/routes/Cargo.toml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
[package]
|
||||||
|
name = "lemmy_routes"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
lemmy_utils = { path = "../utils" }
|
||||||
|
lemmy_websocket = { path = "../websocket" }
|
||||||
|
lemmy_db_queries = { path = "../db_queries" }
|
||||||
|
lemmy_db_views = { path = "../db_views" }
|
||||||
|
lemmy_db_views_actor = { path = "../db_views_actor" }
|
||||||
|
lemmy_db_schema = { path = "../db_schema" }
|
||||||
|
lemmy_structs = { path = "../structs" }
|
||||||
|
diesel = "1.4.5"
|
||||||
|
actix = "0.10.0"
|
||||||
|
actix-web = { version = "3.3.2", default-features = false, features = ["rustls"] }
|
||||||
|
actix-web-actors = { version = "3.0.0", default-features = false }
|
||||||
|
sha2 = "0.9.3"
|
||||||
|
log = "0.4.14"
|
||||||
|
anyhow = "1.0.38"
|
||||||
|
chrono = { version = "0.4.19", features = ["serde"] }
|
||||||
|
rss = "1.10.0"
|
||||||
|
serde = { version = "1.0.123", features = ["derive"] }
|
||||||
|
awc = { version = "2.0.3", default-features = false }
|
||||||
|
url = { version = "2.2.0", features = ["serde"] }
|
||||||
|
strum = "0.20.0"
|
||||||
|
lazy_static = "1.4.0"
|
|
@ -2,7 +2,6 @@ use actix_web::{error::ErrorBadRequest, *};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||||
use diesel::PgConnection;
|
use diesel::PgConnection;
|
||||||
use lemmy_api::claims::Claims;
|
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_queries::{
|
||||||
source::{community::Community_, user::User},
|
source::{community::Community_, user::User},
|
||||||
ListingType,
|
ListingType,
|
||||||
|
@ -16,7 +15,7 @@ use lemmy_db_views::{
|
||||||
};
|
};
|
||||||
use lemmy_db_views_actor::user_mention_view::{UserMentionQueryBuilder, UserMentionView};
|
use lemmy_db_views_actor::user_mention_view::{UserMentionQueryBuilder, UserMentionView};
|
||||||
use lemmy_structs::blocking;
|
use lemmy_structs::blocking;
|
||||||
use lemmy_utils::{settings::Settings, utils::markdown_to_html, LemmyError};
|
use lemmy_utils::{claims::Claims, settings::Settings, utils::markdown_to_html, LemmyError};
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
use rss::{
|
use rss::{
|
||||||
extension::dublincore::DublinCoreExtensionBuilder,
|
extension::dublincore::DublinCoreExtensionBuilder,
|
|
@ -1,8 +1,7 @@
|
||||||
use actix::clock::Duration;
|
use actix::clock::Duration;
|
||||||
use actix_web::{body::BodyStream, http::StatusCode, *};
|
use actix_web::{body::BodyStream, http::StatusCode, *};
|
||||||
use awc::Client;
|
use awc::Client;
|
||||||
use lemmy_api::claims::Claims;
|
use lemmy_utils::{claims::Claims, rate_limit::RateLimit, settings::Settings};
|
||||||
use lemmy_utils::{rate_limit::RateLimit, settings::Settings};
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
|
@ -1,7 +1,7 @@
|
||||||
pub mod api;
|
#[macro_use]
|
||||||
pub mod federation;
|
extern crate lazy_static;
|
||||||
|
|
||||||
pub mod feeds;
|
pub mod feeds;
|
||||||
pub mod images;
|
pub mod images;
|
||||||
pub mod nodeinfo;
|
pub mod nodeinfo;
|
||||||
pub mod webfinger;
|
pub mod webfinger;
|
||||||
pub mod websocket;
|
|
|
@ -1,9 +1,8 @@
|
||||||
use actix_web::{body::Body, error::ErrorBadRequest, *};
|
use actix_web::{body::Body, error::ErrorBadRequest, *};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use lemmy_api::version;
|
|
||||||
use lemmy_db_views::site_view::SiteView;
|
use lemmy_db_views::site_view::SiteView;
|
||||||
use lemmy_structs::blocking;
|
use lemmy_structs::blocking;
|
||||||
use lemmy_utils::{settings::Settings, LemmyError};
|
use lemmy_utils::{settings::Settings, version, LemmyError};
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use url::Url;
|
use url::Url;
|
|
@ -33,3 +33,4 @@ strum_macros = "0.20.1"
|
||||||
futures = "0.3.12"
|
futures = "0.3.12"
|
||||||
diesel = "1.4.5"
|
diesel = "1.4.5"
|
||||||
http = "0.2.3"
|
http = "0.2.3"
|
||||||
|
jsonwebtoken = "7.2.0"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
|
use crate::settings::Settings;
|
||||||
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, TokenData, Validation};
|
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, TokenData, Validation};
|
||||||
use lemmy_db_schema::source::user::User_;
|
|
||||||
use lemmy_utils::settings::Settings;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
type Jwt = String;
|
type Jwt = String;
|
||||||
|
@ -24,9 +23,9 @@ impl Claims {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn jwt(user: User_, hostname: String) -> Result<Jwt, jsonwebtoken::errors::Error> {
|
pub fn jwt(user_id: i32, hostname: String) -> Result<Jwt, jsonwebtoken::errors::Error> {
|
||||||
let my_claims = Claims {
|
let my_claims = Claims {
|
||||||
id: user.id,
|
id: user_id,
|
||||||
iss: hostname,
|
iss: hostname,
|
||||||
};
|
};
|
||||||
encode(
|
encode(
|
|
@ -4,6 +4,7 @@ extern crate lazy_static;
|
||||||
extern crate strum_macros;
|
extern crate strum_macros;
|
||||||
|
|
||||||
pub mod apub;
|
pub mod apub;
|
||||||
|
pub mod claims;
|
||||||
pub mod email;
|
pub mod email;
|
||||||
pub mod rate_limit;
|
pub mod rate_limit;
|
||||||
pub mod request;
|
pub mod request;
|
||||||
|
@ -11,6 +12,7 @@ pub mod settings;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test;
|
mod test;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
pub mod version;
|
||||||
|
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
|
|
|
@ -26,3 +26,5 @@ tokio = "0.3.6"
|
||||||
strum = "0.20.0"
|
strum = "0.20.0"
|
||||||
strum_macros = "0.20.1"
|
strum_macros = "0.20.1"
|
||||||
chrono = { version = "0.4.19", features = ["serde"] }
|
chrono = { version = "0.4.19", features = ["serde"] }
|
||||||
|
actix-web = { version = "3.3.2", default-features = false, features = ["rustls"] }
|
||||||
|
actix-web-actors = { version = "3.0.0", default-features = false }
|
||||||
|
|
|
@ -12,6 +12,7 @@ use serde::Serialize;
|
||||||
pub mod chat_server;
|
pub mod chat_server;
|
||||||
pub mod handlers;
|
pub mod handlers;
|
||||||
pub mod messages;
|
pub mod messages;
|
||||||
|
pub mod routes;
|
||||||
|
|
||||||
pub struct LemmyContext {
|
pub struct LemmyContext {
|
||||||
pub pool: DbPool,
|
pub pool: DbPool,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use actix::prelude::*;
|
use crate::{
|
||||||
use actix_web::*;
|
|
||||||
use actix_web_actors::ws;
|
|
||||||
use lemmy_utils::utils::get_ip;
|
|
||||||
use lemmy_websocket::{
|
|
||||||
chat_server::ChatServer,
|
chat_server::ChatServer,
|
||||||
messages::{Connect, Disconnect, StandardMessage, WSMessage},
|
messages::{Connect, Disconnect, StandardMessage, WSMessage},
|
||||||
LemmyContext,
|
LemmyContext,
|
||||||
};
|
};
|
||||||
|
use actix::prelude::*;
|
||||||
|
use actix_web::*;
|
||||||
|
use actix_web_actors::ws;
|
||||||
|
use lemmy_utils::utils::get_ip;
|
||||||
use log::{debug, error, info};
|
use log::{debug, error, info};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#![recursion_limit = "512"]
|
#![recursion_limit = "512"]
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
pub mod code_migrations;
|
pub mod code_migrations;
|
||||||
pub mod routes;
|
|
||||||
pub mod scheduled_tasks;
|
pub mod scheduled_tasks;
|
||||||
|
|
|
@ -10,7 +10,8 @@ use diesel::{
|
||||||
use lemmy_api::match_websocket_operation;
|
use lemmy_api::match_websocket_operation;
|
||||||
use lemmy_apub::activity_queue::create_activity_queue;
|
use lemmy_apub::activity_queue::create_activity_queue;
|
||||||
use lemmy_db_queries::get_database_url_from_env;
|
use lemmy_db_queries::get_database_url_from_env;
|
||||||
use lemmy_server::{code_migrations::run_advanced_migrations, routes::*, scheduled_tasks};
|
use lemmy_routes::{feeds, images, nodeinfo, webfinger};
|
||||||
|
use lemmy_server::{code_migrations::run_advanced_migrations, scheduled_tasks};
|
||||||
use lemmy_structs::blocking;
|
use lemmy_structs::blocking;
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
rate_limit::{rate_limiter::RateLimiter, RateLimit},
|
rate_limit::{rate_limiter::RateLimiter, RateLimit},
|
||||||
|
@ -86,8 +87,8 @@ async fn main() -> Result<(), LemmyError> {
|
||||||
.wrap(middleware::Logger::default())
|
.wrap(middleware::Logger::default())
|
||||||
.data(context)
|
.data(context)
|
||||||
// The routes
|
// The routes
|
||||||
.configure(|cfg| api::config(cfg, &rate_limiter))
|
.configure(|cfg| lemmy_api::routes::config(cfg, &rate_limiter))
|
||||||
.configure(federation::config)
|
.configure(lemmy_apub::routes::config)
|
||||||
.configure(feeds::config)
|
.configure(feeds::config)
|
||||||
.configure(|cfg| images::config(cfg, &rate_limiter))
|
.configure(|cfg| images::config(cfg, &rate_limiter))
|
||||||
.configure(nodeinfo::config)
|
.configure(nodeinfo::config)
|
||||||
|
|
Loading…
Reference in a new issue