]> Untitled Git - lemmy.git/commitdiff
Move routes into separate crate to speed up compilation
authorFelix Ableitner <me@nutomic.com>
Tue, 9 Feb 2021 18:26:06 +0000 (19:26 +0100)
committerFelix Ableitner <me@nutomic.com>
Tue, 9 Feb 2021 18:34:36 +0000 (19:34 +0100)
25 files changed:
Cargo.lock
Cargo.toml
crates/api/Cargo.toml
crates/api/src/lib.rs
crates/api/src/routes.rs [moved from src/routes/api.rs with 98% similarity]
crates/api/src/site.rs
crates/api/src/user.rs
crates/apub/src/lib.rs
crates/apub/src/routes.rs [moved from src/routes/federation.rs with 99% similarity]
crates/db_queries/Cargo.toml
crates/routes/Cargo.toml [new file with mode: 0644]
crates/routes/src/feeds.rs [moved from src/routes/feeds.rs with 99% similarity]
crates/routes/src/images.rs [moved from src/routes/images.rs with 97% similarity]
crates/routes/src/lib.rs [moved from src/routes/mod.rs with 56% similarity]
crates/routes/src/nodeinfo.rs [moved from src/routes/nodeinfo.rs with 97% similarity]
crates/routes/src/webfinger.rs [moved from src/routes/webfinger.rs with 100% similarity]
crates/utils/Cargo.toml
crates/utils/src/claims.rs [moved from crates/api/src/claims.rs with 80% similarity]
crates/utils/src/lib.rs
crates/utils/src/version.rs [moved from crates/api/src/version.rs with 100% similarity]
crates/websocket/Cargo.toml
crates/websocket/src/lib.rs
crates/websocket/src/routes.rs [moved from src/routes/websocket.rs with 99% similarity]
src/lib.rs
src/main.rs

index 8553c1f2cec99c934df5599409399bfc38340185..2edcca8d7d3dd89bbc53bf0f285eb07cd6f2502c 100644 (file)
@@ -88,26 +88,6 @@ dependencies = [
  "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]]
 name = "actix-http"
 version = "2.2.0"
@@ -662,15 +642,6 @@ dependencies = [
  "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]]
 name = "bumpalo"
 version = "3.6.0"
@@ -836,7 +807,7 @@ checksum = "784ad0fbab4f3e9cef09f20e0aea6000ae08d2cb98ac4c0abc53df18803d702f"
 dependencies = [
  "percent-encoding",
  "time 0.2.25",
- "version_check 0.9.2",
+ "version_check",
 ]
 
 [[package]]
@@ -1050,17 +1021,6 @@ dependencies = [
  "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]]
 name = "diesel_migrations"
 version = "1.4.0"
@@ -1356,7 +1316,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
 dependencies = [
  "typenum",
- "version_check 0.9.2",
+ "version_check",
 ]
 
 [[package]]
@@ -1771,7 +1731,6 @@ dependencies = [
  "http",
  "http-signature-normalization-actix",
  "itertools",
- "jsonwebtoken",
  "lazy_static",
  "lemmy_apub",
  "lemmy_db_queries",
@@ -1851,7 +1810,6 @@ dependencies = [
  "bcrypt",
  "chrono",
  "diesel",
- "diesel_json",
  "diesel_migrations",
  "lazy_static",
  "lemmy_db_schema",
@@ -1910,18 +1868,42 @@ dependencies = [
  "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]]
 name = "lemmy_server"
 version = "0.0.1"
 dependencies = [
  "activitystreams",
  "actix",
- "actix-files",
  "actix-rt",
  "actix-web",
- "actix-web-actors",
  "anyhow",
- "awc",
  "cargo-husky",
  "chrono",
  "clokwerk",
@@ -1929,7 +1911,6 @@ dependencies = [
  "diesel_migrations",
  "env_logger",
  "http-signature-normalization-actix",
- "lazy_static",
  "lemmy_api",
  "lemmy_apub",
  "lemmy_db_queries",
@@ -1937,16 +1918,15 @@ dependencies = [
  "lemmy_db_views",
  "lemmy_db_views_actor",
  "lemmy_db_views_moderator",
+ "lemmy_routes",
  "lemmy_structs",
  "lemmy_utils",
  "lemmy_websocket",
  "log",
  "openssl",
  "reqwest",
- "rss",
  "serde 1.0.123",
  "serde_json",
- "sha2",
  "strum",
  "tokio 0.3.7",
  "url",
@@ -1985,6 +1965,7 @@ dependencies = [
  "futures",
  "http",
  "itertools",
+ "jsonwebtoken",
  "lazy_static",
  "lettre",
  "log",
@@ -2007,6 +1988,8 @@ name = "lemmy_websocket"
 version = "0.1.0"
 dependencies = [
  "actix",
+ "actix-web",
+ "actix-web-actors",
  "anyhow",
  "background-jobs",
  "chrono",
@@ -2288,16 +2271,6 @@ dependencies = [
  "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]]
 name = "nom"
 version = "5.1.2"
@@ -2306,7 +2279,7 @@ checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
 dependencies = [
  "lexical-core",
  "memchr",
- "version_check 0.9.2",
+ "version_check",
 ]
 
 [[package]]
@@ -2317,7 +2290,7 @@ checksum = "ab6f70b46d6325aa300f1c7bb3d470127dfc27806d8ea6bf294ee0ce643ce2b1"
 dependencies = [
  "bitvec",
  "memchr",
- "version_check 0.9.2",
+ "version_check",
 ]
 
 [[package]]
@@ -3212,7 +3185,7 @@ version = "0.2.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c66a8cff4fa24853fdf6b51f75c6d7f8206d7c75cab4e467bcd7f25c2b1febe0"
 dependencies = [
- "version_check 0.9.2",
+ "version_check",
 ]
 
 [[package]]
@@ -3405,7 +3378,7 @@ dependencies = [
  "standback",
  "stdweb",
  "time-macros",
- "version_check 0.9.2",
+ "version_check",
  "winapi 0.3.9",
 ]
 
@@ -3638,7 +3611,7 @@ version = "2.6.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
 dependencies = [
- "version_check 0.9.2",
+ "version_check",
 ]
 
 [[package]]
@@ -3706,50 +3679,12 @@ dependencies = [
  "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]]
 name = "vcpkg"
 version = "0.2.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb"
 
-[[package]]
-name = "version_check"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
-
 [[package]]
 name = "version_check"
 version = "0.9.2"
index 8df7e8048ff1467f27aa7e3406c62ad60e6b9254..edec85f60ee6d394eafa687b6d60e53febed5ddf 100644 (file)
@@ -18,6 +18,7 @@ members = [
     "crates/db_views_actor",
     "crates/structs",
     "crates/websocket",
+    "crates/routes"
 ]
 
 [dependencies]
@@ -31,25 +32,20 @@ lemmy_db_views_moderator = { path = "./crates/db_views_moderator" }
 lemmy_db_views_actor = { path = "./crates/db_views_actor" }
 lemmy_structs = { path = "./crates/structs" }
 lemmy_websocket = { path = "./crates/websocket" }
+lemmy_routes = { path = "./crates/routes" }
 diesel = "1.4.5"
 diesel_migrations = "1.4.0"
 chrono = { version = "0.4.19", features = ["serde"] }
 serde = { version = "1.0.123", features = ["derive"] }
 actix = "0.10.0"
 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"
 env_logger = "0.8.2"
 strum = "0.20.0"
-lazy_static = "1.4.0"
-rss = "1.10.0"
 url = { version = "2.2.0", features = ["serde"] }
 openssl = "0.10.32"
 http-signature-normalization-actix = { version = "0.4.1", default-features = false, features = ["sha-2"] }
 tokio = "0.3.6"
-sha2 = "0.9.3"
 anyhow = "1.0.38"
 reqwest = { version = "0.10.10", features = ["json"] }
 activitystreams = "0.7.0-alpha.10"
index 37968ae9419468ca32fca831ba92f6f8f6c9cdde..e3226eb8581ca2f104474a2192978af5e855c924 100644 (file)
@@ -31,7 +31,6 @@ log = "0.4.14"
 rand = "0.8.3"
 strum = "0.20.0"
 strum_macros = "0.20.1"
-jsonwebtoken = "7.2.0"
 lazy_static = "1.4.0"
 url = { version = "2.2.0", features = ["serde"] }
 openssl = "0.10.32"
index 161540d53aac423be7ff2dcf46255b13c25f8f9e..5e9e1c1624628cc78f8b329d1d51ddbd9aa57d1f 100644 (file)
@@ -1,4 +1,3 @@
-use crate::claims::Claims;
 use actix_web::{web, web::Data};
 use lemmy_db_queries::{
   source::{
@@ -20,19 +19,18 @@ use lemmy_db_views_actor::{
   community_view::CommunityView,
 };
 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 serde::Deserialize;
 use std::process::Command;
 use url::Url;
 
-pub mod claims;
 pub mod comment;
 pub mod community;
 pub mod post;
+pub mod routes;
 pub mod site;
 pub mod user;
-pub mod version;
 pub mod websocket;
 
 #[async_trait::async_trait(?Send)]
similarity index 98%
rename from src/routes/api.rs
rename to crates/api/src/routes.rs
index 1f5a54544e838a0c14112ea8c58e73d5801b68aa..a55dec5f2e57f28bde5e91c55822c76891c3f83b 100644 (file)
@@ -1,15 +1,15 @@
+use crate::Perform;
 use actix_web::{error::ErrorBadRequest, *};
-use lemmy_api::Perform;
 use lemmy_structs::{comment::*, community::*, post::*, site::*, user::*, websocket::*};
 use lemmy_utils::rate_limit::RateLimit;
-use lemmy_websocket::LemmyContext;
+use lemmy_websocket::{routes::chat_route, LemmyContext};
 use serde::Deserialize;
 
 pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
   cfg.service(
     web::scope("/api/v2")
       // Websockets
-      .service(web::resource("/ws").to(super::websocket::chat_route))
+      .service(web::resource("/ws").to(chat_route))
       // Site
       .service(
         web::scope("/site")
index 96ce50cab6476683f3bf96babf33251ab2f52a91..1bdce91abd2ce7c5c77d0c171b7163a0683f9f8d 100644 (file)
@@ -5,7 +5,6 @@ use crate::{
   get_user_safe_settings_from_jwt,
   get_user_safe_settings_from_jwt_opt,
   is_admin,
-  version,
   Perform,
 };
 use actix_web::web::Data;
@@ -51,6 +50,7 @@ use lemmy_utils::{
   location_info,
   settings::Settings,
   utils::{check_slurs, check_slurs_opt},
+  version,
   APIError,
   ConnectionId,
   LemmyError,
index fe124f23e21c3cf52dedb06eb853c2f6d22d4f03..da2b8f30ddbc3972e1a368ffdbd830786c1a09b4 100644 (file)
@@ -1,7 +1,6 @@
 use crate::{
   captcha_espeak_wav_base64,
   check_optional_url,
-  claims::Claims,
   collect_moderated_communities,
   get_user_from_jwt,
   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_utils::{
   apub::generate_actor_keypair,
+  claims::Claims,
   email::send_email,
   location_info,
   settings::Settings,
@@ -121,7 +121,7 @@ impl Perform for Login {
 
     // Return the jwt
     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
     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
     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
     Ok(LoginResponse {
-      jwt: Claims::jwt(updated_user, Settings::get().hostname)?,
+      jwt: Claims::jwt(updated_user.id, Settings::get().hostname)?,
     })
   }
 }
index 0b3fee437ca86705e7c35a03f75e537fcd9228c8..388d57e6a9b5f3292e973e5e14a23464dc280479 100644 (file)
@@ -8,6 +8,7 @@ pub mod fetcher;
 pub mod http;
 pub mod inbox;
 pub mod objects;
+pub mod routes;
 
 use crate::extensions::{
   group_extensions::GroupExtension,
similarity index 99%
rename from src/routes/federation.rs
rename to crates/apub/src/routes.rs
index 27f596837491e6efe425fc84b02aa759e874e24d..3717a894f09e336e7d26bd904678ac38b2964657 100644 (file)
@@ -1,6 +1,4 @@
-use actix_web::*;
-use http_signature_normalization_actix::digest::middleware::VerifyDigest;
-use lemmy_apub::{
+use crate::{
   http::{
     comment::get_apub_comment,
     community::{
@@ -16,6 +14,8 @@ use lemmy_apub::{
   inbox::{community_inbox::community_inbox, shared_inbox::shared_inbox, user_inbox::user_inbox},
   APUB_JSON_CONTENT_TYPE,
 };
+use actix_web::*;
+use http_signature_normalization_actix::digest::middleware::VerifyDigest;
 use lemmy_utils::settings::Settings;
 use sha2::{Digest, Sha256};
 
index a25b80ffbbeca08df1c36806c9566dfa05f5506c..c396b39a3e2497bd985507491ffccbac59b970c0 100644 (file)
@@ -23,4 +23,3 @@ url = { version = "2.2.0", features = ["serde"] }
 lazy_static = "1.4.0"
 regex = "1.4.3"
 bcrypt = "0.9.0"
-diesel_json = "0.1.1"
diff --git a/crates/routes/Cargo.toml b/crates/routes/Cargo.toml
new file mode 100644 (file)
index 0000000..0c5eac6
--- /dev/null
@@ -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"
similarity index 99%
rename from src/routes/feeds.rs
rename to crates/routes/src/feeds.rs
index 864670527812bca8f870bdd88fec012d3c761beb..163452a82117bf261df217794e96de1c5cd83749 100644 (file)
@@ -2,7 +2,6 @@ use actix_web::{error::ErrorBadRequest, *};
 use anyhow::anyhow;
 use chrono::{DateTime, NaiveDateTime, Utc};
 use diesel::PgConnection;
-use lemmy_api::claims::Claims;
 use lemmy_db_queries::{
   source::{community::Community_, user::User},
   ListingType,
@@ -16,7 +15,7 @@ use lemmy_db_views::{
 };
 use lemmy_db_views_actor::user_mention_view::{UserMentionQueryBuilder, UserMentionView};
 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 rss::{
   extension::dublincore::DublinCoreExtensionBuilder,
similarity index 97%
rename from src/routes/images.rs
rename to crates/routes/src/images.rs
index c9937ee689cd123b64b5ca5820513d5c18eacf58..4d7656e1b2436abf8919a7cf910912d05c671aca 100644 (file)
@@ -1,8 +1,7 @@
 use actix::clock::Duration;
 use actix_web::{body::BodyStream, http::StatusCode, *};
 use awc::Client;
-use lemmy_api::claims::Claims;
-use lemmy_utils::{rate_limit::RateLimit, settings::Settings};
+use lemmy_utils::{claims::Claims, rate_limit::RateLimit, settings::Settings};
 use serde::{Deserialize, Serialize};
 
 pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
similarity index 56%
rename from src/routes/mod.rs
rename to crates/routes/src/lib.rs
index f3cf8b125286cc8117399b414c4341928240bd2a..b966b766acb3026bc711d60b2147803c4b702253 100644 (file)
@@ -1,7 +1,7 @@
-pub mod api;
-pub mod federation;
+#[macro_use]
+extern crate lazy_static;
+
 pub mod feeds;
 pub mod images;
 pub mod nodeinfo;
 pub mod webfinger;
-pub mod websocket;
similarity index 97%
rename from src/routes/nodeinfo.rs
rename to crates/routes/src/nodeinfo.rs
index e7eb9486f80eb153eb3c3d0b8a24e30bb8945221..46ef7ce4dfec70ff9acee6861e201b814cc83484 100644 (file)
@@ -1,9 +1,8 @@
 use actix_web::{body::Body, error::ErrorBadRequest, *};
 use anyhow::anyhow;
-use lemmy_api::version;
 use lemmy_db_views::site_view::SiteView;
 use lemmy_structs::blocking;
-use lemmy_utils::{settings::Settings, LemmyError};
+use lemmy_utils::{settings::Settings, version, LemmyError};
 use lemmy_websocket::LemmyContext;
 use serde::{Deserialize, Serialize};
 use url::Url;
index 35df30649d2e8b8016c5a3e405fcb3f79498642a..c10b7c2c7ffec0afdd14d4bd219c4e5ea50432a5 100644 (file)
@@ -33,3 +33,4 @@ strum_macros = "0.20.1"
 futures = "0.3.12"
 diesel = "1.4.5"
 http = "0.2.3"
+jsonwebtoken = "7.2.0"
similarity index 80%
rename from crates/api/src/claims.rs
rename to crates/utils/src/claims.rs
index f99730bdd3e1f0292a6b9b0ff629b655b7d09534..dff79d859ce623fdc6df38d39d5ac04e6aa92088 100644 (file)
@@ -1,6 +1,5 @@
+use crate::settings::Settings;
 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};
 
 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 {
-      id: user.id,
+      id: user_id,
       iss: hostname,
     };
     encode(
index 2cc29131fe7774648bb2a6111851dedba373a3ce..6d8265aa3fbb95a026077102f3356a359014f320 100644 (file)
@@ -4,6 +4,7 @@ extern crate lazy_static;
 extern crate strum_macros;
 
 pub mod apub;
+pub mod claims;
 pub mod email;
 pub mod rate_limit;
 pub mod request;
@@ -11,6 +12,7 @@ pub mod settings;
 #[cfg(test)]
 mod test;
 pub mod utils;
+pub mod version;
 
 use crate::settings::Settings;
 use http::StatusCode;
index 0329cef13284f6775982b1b61f2cbd97cf3d590a..1cb71ea1df7f6bff30150712fda89c19fca50bed 100644 (file)
@@ -26,3 +26,5 @@ tokio = "0.3.6"
 strum = "0.20.0"
 strum_macros = "0.20.1"
 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 }
index 72e72b52f9b8c2df8925c38e08fba39938099c15..2144ffefb1c33fec62912a45a975f17138f68aa3 100644 (file)
@@ -12,6 +12,7 @@ use serde::Serialize;
 pub mod chat_server;
 pub mod handlers;
 pub mod messages;
+pub mod routes;
 
 pub struct LemmyContext {
   pub pool: DbPool,
similarity index 99%
rename from src/routes/websocket.rs
rename to crates/websocket/src/routes.rs
index 9bfd6ca14778f83ef9d7234972a3b250dae79178..890b7be53599c0b07db5926137d2ed79c89d21cb 100644 (file)
@@ -1,12 +1,12 @@
-use actix::prelude::*;
-use actix_web::*;
-use actix_web_actors::ws;
-use lemmy_utils::utils::get_ip;
-use lemmy_websocket::{
+use crate::{
   chat_server::ChatServer,
   messages::{Connect, Disconnect, StandardMessage, WSMessage},
   LemmyContext,
 };
+use actix::prelude::*;
+use actix_web::*;
+use actix_web_actors::ws;
+use lemmy_utils::utils::get_ip;
 use log::{debug, error, info};
 use std::time::{Duration, Instant};
 
index e867a26b320d81180b946549c1203be6d2ad3936..16cddf6319c9ea822ce5125bf4fd611ea172ec46 100644 (file)
@@ -1,6 +1,3 @@
 #![recursion_limit = "512"]
-#[macro_use]
-extern crate lazy_static;
 pub mod code_migrations;
-pub mod routes;
 pub mod scheduled_tasks;
index 1f7b36f618d538e9cda911e6fd36d9daeea922a7..4ebedb4f849f41cb6c46e430808cead6f9aaf10d 100644 (file)
@@ -10,7 +10,8 @@ use diesel::{
 use lemmy_api::match_websocket_operation;
 use lemmy_apub::activity_queue::create_activity_queue;
 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_utils::{
   rate_limit::{rate_limiter::RateLimiter, RateLimit},
@@ -86,8 +87,8 @@ async fn main() -> Result<(), LemmyError> {
       .wrap(middleware::Logger::default())
       .data(context)
       // The routes
-      .configure(|cfg| api::config(cfg, &rate_limiter))
-      .configure(federation::config)
+      .configure(|cfg| lemmy_api::routes::config(cfg, &rate_limiter))
+      .configure(lemmy_apub::routes::config)
       .configure(feeds::config)
       .configure(|cfg| images::config(cfg, &rate_limiter))
       .configure(nodeinfo::config)