"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"
"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"
dependencies = [
"percent-encoding",
"time 0.2.25",
- "version_check 0.9.2",
+ "version_check",
]
[[package]]
"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"
checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
dependencies = [
"typenum",
- "version_check 0.9.2",
+ "version_check",
]
[[package]]
"http",
"http-signature-normalization-actix",
"itertools",
- "jsonwebtoken",
"lazy_static",
"lemmy_apub",
"lemmy_db_queries",
"bcrypt",
"chrono",
"diesel",
- "diesel_json",
"diesel_migrations",
"lazy_static",
"lemmy_db_schema",
"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",
"diesel_migrations",
"env_logger",
"http-signature-normalization-actix",
- "lazy_static",
"lemmy_api",
"lemmy_apub",
"lemmy_db_queries",
"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",
"futures",
"http",
"itertools",
+ "jsonwebtoken",
"lazy_static",
"lettre",
"log",
version = "0.1.0"
dependencies = [
"actix",
+ "actix-web",
+ "actix-web-actors",
"anyhow",
"background-jobs",
"chrono",
"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"
dependencies = [
"lexical-core",
"memchr",
- "version_check 0.9.2",
+ "version_check",
]
[[package]]
dependencies = [
"bitvec",
"memchr",
- "version_check 0.9.2",
+ "version_check",
]
[[package]]
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c66a8cff4fa24853fdf6b51f75c6d7f8206d7c75cab4e467bcd7f25c2b1febe0"
dependencies = [
- "version_check 0.9.2",
+ "version_check",
]
[[package]]
"standback",
"stdweb",
"time-macros",
- "version_check 0.9.2",
+ "version_check",
"winapi 0.3.9",
]
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
dependencies = [
- "version_check 0.9.2",
+ "version_check",
]
[[package]]
"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"
"crates/db_views_actor",
"crates/structs",
"crates/websocket",
+ "crates/routes"
]
[dependencies]
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"
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"
-use crate::claims::Claims;
use actix_web::{web, web::Data};
use lemmy_db_queries::{
source::{
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)]
+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")
get_user_safe_settings_from_jwt,
get_user_safe_settings_from_jwt_opt,
is_admin,
- version,
Perform,
};
use actix_web::web::Data;
location_info,
settings::Settings,
utils::{check_slurs, check_slurs_opt},
+ version,
APIError,
ConnectionId,
LemmyError,
use crate::{
captcha_espeak_wav_base64,
check_optional_url,
- claims::Claims,
collect_moderated_communities,
get_user_from_jwt,
get_user_from_jwt_opt,
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,
// Return the jwt
Ok(LoginResponse {
- jwt: Claims::jwt(user, Settings::get().hostname)?,
+ jwt: Claims::jwt(user.id, Settings::get().hostname)?,
})
}
}
// Return the jwt
Ok(LoginResponse {
- jwt: Claims::jwt(inserted_user, Settings::get().hostname)?,
+ jwt: Claims::jwt(inserted_user.id, Settings::get().hostname)?,
})
}
}
// Return the jwt
Ok(LoginResponse {
- jwt: Claims::jwt(updated_user, Settings::get().hostname)?,
+ jwt: Claims::jwt(updated_user.id, Settings::get().hostname)?,
})
}
}
// Return the jwt
Ok(LoginResponse {
- jwt: Claims::jwt(updated_user, Settings::get().hostname)?,
+ jwt: Claims::jwt(updated_user.id, Settings::get().hostname)?,
})
}
}
pub mod http;
pub mod inbox;
pub mod objects;
+pub mod routes;
use crate::extensions::{
group_extensions::GroupExtension,
-use actix_web::*;
-use http_signature_normalization_actix::digest::middleware::VerifyDigest;
-use lemmy_apub::{
+use crate::{
http::{
comment::get_apub_comment,
community::{
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};
lazy_static = "1.4.0"
regex = "1.4.3"
bcrypt = "0.9.0"
-diesel_json = "0.1.1"
--- /dev/null
+[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"
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,
};
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,
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) {
-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;
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;
futures = "0.3.12"
diesel = "1.4.5"
http = "0.2.3"
+jsonwebtoken = "7.2.0"
+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;
)
}
- 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(
extern crate strum_macros;
pub mod apub;
+pub mod claims;
pub mod email;
pub mod rate_limit;
pub mod request;
#[cfg(test)]
mod test;
pub mod utils;
+pub mod version;
use crate::settings::Settings;
use http::StatusCode;
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 }
pub mod chat_server;
pub mod handlers;
pub mod messages;
+pub mod routes;
pub struct LemmyContext {
pub pool: DbPool,
-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};
#![recursion_limit = "512"]
-#[macro_use]
-extern crate lazy_static;
pub mod code_migrations;
-pub mod routes;
pub mod scheduled_tasks;
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},
.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)