Merge branch 'main' into apub-receive-rewrite

This commit is contained in:
Felix Ableitner 2021-07-09 06:55:08 +02:00
commit 184517c969
24 changed files with 1976 additions and 2891 deletions

1757
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -42,25 +42,25 @@ lemmy_db_views_actor = { path = "./crates/db_views_actor" }
lemmy_api_common = { path = "crates/api_common" } lemmy_api_common = { path = "crates/api_common" }
lemmy_websocket = { path = "./crates/websocket" } lemmy_websocket = { path = "./crates/websocket" }
lemmy_routes = { path = "./crates/routes" } lemmy_routes = { path = "./crates/routes" }
diesel = "1.4.5" diesel = "1.4.7"
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.126", features = ["derive"] }
actix = "0.10.0" actix = "0.12.0"
actix-web = { version = "3.3.2", default-features = false, features = ["rustls"] } actix-web = { version = "4.0.0-beta.8", default-features = false, features = ["rustls"] }
log = "0.4.14" log = "0.4.14"
env_logger = "0.8.2" env_logger = "0.8.4"
strum = "0.20.0" strum = "0.21.0"
url = { version = "2.2.1", features = ["serde"] } url = { version = "2.2.2", features = ["serde"] }
openssl = "0.10.32" openssl = "0.10.35"
http-signature-normalization-actix = { version = "0.4.1", default-features = false, features = ["sha-2"] } http-signature-normalization-actix = { version = "0.5.0-beta.6", default-features = false, features = ["sha-2"] }
tokio = "0.3.6" tokio = { version = "1.8.0", features = ["sync"] }
anyhow = "1.0.38" anyhow = "1.0.41"
reqwest = { version = "0.10.10", features = ["json"] } reqwest = { version = "0.11.4", features = ["json"] }
activitystreams = "0.7.0-alpha.10" activitystreams = "0.7.0-alpha.11"
actix-rt = { version = "1.1.1", default-features = false } actix-rt = { version = "2.2.0", default-features = false }
serde_json = { version = "1.0.61", features = ["preserve_order"] } serde_json = { version = "1.0.64", features = ["preserve_order"] }
clokwerk = "0.3.4" clokwerk = "0.3.5"
[dev-dependencies.cargo-husky] [dev-dependencies.cargo-husky]
version = "1.5.0" version = "1.5.0"

View file

@ -13,13 +13,13 @@
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.23", "@types/jest": "^26.0.23",
"eslint": "^7.26.0", "eslint": "^7.30.0",
"eslint-plugin-jane": "^9.0.3", "eslint-plugin-jane": "^9.0.3",
"jest": "^26.6.3", "jest": "^27.0.6",
"lemmy-js-client": "0.11.0-rc.3", "lemmy-js-client": "0.11.0-rc.3",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",
"prettier": "^2.3.0", "prettier": "^2.3.2",
"ts-jest": "^26.5.6", "ts-jest": "^27.0.3",
"typescript": "^4.2.4" "typescript": "^4.3.5"
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -18,33 +18,33 @@ lemmy_db_views_moderator = { path = "../db_views_moderator" }
lemmy_db_views_actor = { path = "../db_views_actor" } lemmy_db_views_actor = { path = "../db_views_actor" }
lemmy_api_common = { path = "../api_common" } lemmy_api_common = { path = "../api_common" }
lemmy_websocket = { path = "../websocket" } lemmy_websocket = { path = "../websocket" }
diesel = "1.4.5" diesel = "1.4.7"
bcrypt = "0.9.0" bcrypt = "0.10.0"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }
serde_json = { version = "1.0.61", features = ["preserve_order"] } serde_json = { version = "1.0.64", features = ["preserve_order"] }
serde = { version = "1.0.123", features = ["derive"] } serde = { version = "1.0.126", features = ["derive"] }
actix = "0.10.0" actix = "0.12.0"
actix-web = { version = "3.3.2", default-features = false } actix-web = { version = "4.0.0-beta.8", default-features = false }
actix-rt = { version = "1.1.1", default-features = false } actix-rt = { version = "2.2.0", default-features = false }
awc = { version = "2.0.3", default-features = false } awc = { version = "3.0.0-beta.7", default-features = false }
log = "0.4.14" log = "0.4.14"
rand = "0.8.3" rand = "0.8.4"
strum = "0.20.0" strum = "0.21.0"
strum_macros = "0.20.1" strum_macros = "0.21.1"
lazy_static = "1.4.0" lazy_static = "1.4.0"
url = { version = "2.2.1", features = ["serde"] } url = { version = "2.2.2", features = ["serde"] }
openssl = "0.10.32" openssl = "0.10.35"
http = "0.2.3" http = "0.2.4"
http-signature-normalization-actix = { version = "0.4.1", default-features = false, features = ["sha-2"] } http-signature-normalization-actix = { version = "0.5.0-beta.6", default-features = false, features = ["sha-2"] }
base64 = "0.13.0" base64 = "0.13.0"
tokio = "0.3.6" tokio = "1.8.0"
futures = "0.3.12" futures = "0.3.15"
itertools = "0.10.0" itertools = "0.10.1"
uuid = { version = "0.8.2", features = ["serde", "v4"] } uuid = { version = "0.8.2", features = ["serde", "v4"] }
sha2 = "0.9.3" sha2 = "0.9.5"
async-trait = "0.1.42" async-trait = "0.1.50"
captcha = "0.0.8" captcha = "0.0.8"
anyhow = "1.0.38" anyhow = "1.0.41"
thiserror = "1.0.26" thiserror = "1.0.26"
background-jobs = "0.8.0" background-jobs = "0.9.0"
reqwest = { version = "0.10.10", features = ["json"] } reqwest = { version = "0.11.4", features = ["json"] }

View file

@ -15,10 +15,10 @@ lemmy_db_views_moderator = { path = "../db_views_moderator" }
lemmy_db_views_actor = { path = "../db_views_actor" } lemmy_db_views_actor = { path = "../db_views_actor" }
lemmy_db_schema = { path = "../db_schema" } lemmy_db_schema = { path = "../db_schema" }
lemmy_utils = { path = "../utils" } lemmy_utils = { path = "../utils" }
serde = { version = "1.0.123", features = ["derive"] } serde = { version = "1.0.126", features = ["derive"] }
log = "0.4.14" log = "0.4.14"
diesel = "1.4.5" diesel = "1.4.7"
actix-web = "3.3.2" actix-web = "4.0.0-beta.8"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }
serde_json = { version = "1.0.61", features = ["preserve_order"] } serde_json = { version = "1.0.64", features = ["preserve_order"] }
url = "2.2.1" url = "2.2.2"

View file

@ -73,11 +73,11 @@ where
let res = actix_web::web::block(move || { let res = actix_web::web::block(move || {
let conn = pool.get()?; let conn = pool.get()?;
let res = (f)(&conn); let res = (f)(&conn);
Ok(res) as Result<_, LemmyError> Ok(res) as Result<T, LemmyError>
}) })
.await?; .await?;
Ok(res) res
} }
pub async fn send_local_notifs( pub async fn send_local_notifs(

View file

@ -13,32 +13,32 @@ lemmy_db_views_moderator = { path = "../db_views_moderator" }
lemmy_db_views_actor = { path = "../db_views_actor" } lemmy_db_views_actor = { path = "../db_views_actor" }
lemmy_api_common = { path = "../api_common" } lemmy_api_common = { path = "../api_common" }
lemmy_websocket = { path = "../websocket" } lemmy_websocket = { path = "../websocket" }
diesel = "1.4.5" diesel = "1.4.7"
bcrypt = "0.9.0" bcrypt = "0.10.0"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }
serde_json = { version = "1.0.61", features = ["preserve_order"] } serde_json = { version = "1.0.64", features = ["preserve_order"] }
serde = { version = "1.0.123", features = ["derive"] } serde = { version = "1.0.126", features = ["derive"] }
actix = "0.10.0" actix = "0.12.0"
actix-web = { version = "3.3.2", default-features = false } actix-web = { version = "4.0.0-beta.8", default-features = false }
actix-rt = { version = "1.1.1", default-features = false } actix-rt = { version = "2.2.0", default-features = false }
awc = { version = "2.0.3", default-features = false } awc = { version = "3.0.0-beta.7", default-features = false }
log = "0.4.14" log = "0.4.14"
rand = "0.8.3" rand = "0.8.4"
strum = "0.20.0" strum = "0.21.0"
strum_macros = "0.20.1" strum_macros = "0.21.1"
lazy_static = "1.4.0" lazy_static = "1.4.0"
url = { version = "2.2.1", features = ["serde"] } url = { version = "2.2.2", features = ["serde"] }
openssl = "0.10.32" openssl = "0.10.35"
http = "0.2.3" http = "0.2.4"
http-signature-normalization-actix = { version = "0.4.1", default-features = false, features = ["sha-2"] } http-signature-normalization-actix = { version = "0.5.0-beta.6", default-features = false, features = ["sha-2"] }
base64 = "0.13.0" base64 = "0.13.0"
tokio = "0.3.6" tokio = "1.8.0"
futures = "0.3.12" futures = "0.3.15"
itertools = "0.10.0" itertools = "0.10.1"
uuid = { version = "0.8.2", features = ["serde", "v4"] } uuid = { version = "0.8.2", features = ["serde", "v4"] }
sha2 = "0.9.3" sha2 = "0.9.5"
async-trait = "0.1.42" async-trait = "0.1.50"
anyhow = "1.0.38" anyhow = "1.0.41"
thiserror = "1.0.26" thiserror = "1.0.26"
background-jobs = "0.8.0" background-jobs = "0.9.0"
reqwest = { version = "0.10.10", features = ["json"] } reqwest = { version = "0.11.4", features = ["json"] }

View file

@ -16,37 +16,37 @@ lemmy_db_views = { path = "../db_views" }
lemmy_db_views_actor = { path = "../db_views_actor" } lemmy_db_views_actor = { path = "../db_views_actor" }
lemmy_api_common = { path = "../api_common" } lemmy_api_common = { path = "../api_common" }
lemmy_websocket = { path = "../websocket" } lemmy_websocket = { path = "../websocket" }
diesel = "1.4.5" diesel = "1.4.7"
activitystreams = "0.7.0-alpha.11" activitystreams = "0.7.0-alpha.11"
activitystreams-ext = "0.1.0-alpha.2" activitystreams-ext = "0.1.0-alpha.2"
bcrypt = "0.9.0" bcrypt = "0.10.0"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }
serde_json = { version = "1.0.61", features = ["preserve_order"] } serde_json = { version = "1.0.64", features = ["preserve_order"] }
serde = { version = "1.0.123", features = ["derive"] } serde = { version = "1.0.126", features = ["derive"] }
actix = "0.10.0" actix = "0.12.0"
actix-web = { version = "3.3.2", default-features = false } actix-web = { version = "4.0.0-beta.8", default-features = false }
actix-rt = { version = "1.1.1", default-features = false } actix-rt = { version = "2.2.0", default-features = false }
awc = { version = "2.0.3", default-features = false } awc = { version = "3.0.0-beta.7", default-features = false }
log = "0.4.14" log = "0.4.14"
rand = "0.8.3" rand = "0.8.4"
strum = "0.20.0" strum = "0.21.0"
strum_macros = "0.20.1" strum_macros = "0.21.1"
lazy_static = "1.4.0" lazy_static = "1.4.0"
url = { version = "2.2.1", features = ["serde"] } url = { version = "2.2.2", features = ["serde"] }
percent-encoding = "2.1.0" percent-encoding = "2.1.0"
openssl = "0.10.32" openssl = "0.10.35"
http = "0.2.3" http = "0.2.4"
http-signature-normalization-actix = { version = "0.4.1", default-features = false, features = ["sha-2"] } http-signature-normalization-actix = { version = "0.5.0-beta.6", default-features = false, features = ["sha-2"] }
http-signature-normalization-reqwest = { version = "0.1.3", default-features = false, features = ["sha-2"] } http-signature-normalization-reqwest = { version = "0.2.0", default-features = false, features = ["sha-2"] }
base64 = "0.13.0" base64 = "0.13.0"
tokio = "0.3.6" tokio = "1.8.0"
futures = "0.3.12" futures = "0.3.15"
itertools = "0.10.0" itertools = "0.10.1"
uuid = { version = "0.8.2", features = ["serde", "v4"] } uuid = { version = "0.8.2", features = ["serde", "v4"] }
sha2 = "0.9.3" sha2 = "0.9.5"
async-trait = "0.1.42" async-trait = "0.1.50"
anyhow = "1.0.38" anyhow = "1.0.41"
thiserror = "1.0.26" thiserror = "1.0.26"
background-jobs = "0.8.0" background-jobs = "0.9.0"
reqwest = { version = "0.10.10", features = ["json"] } reqwest = { version = "0.11.4", features = ["json"] }
backtrace = "0.3.56" backtrace = "0.3.60"

View file

@ -13,34 +13,34 @@ lemmy_db_views = { path = "../db_views" }
lemmy_db_views_actor = { path = "../db_views_actor" } lemmy_db_views_actor = { path = "../db_views_actor" }
lemmy_api_common = { path = "../api_common" } lemmy_api_common = { path = "../api_common" }
lemmy_websocket = { path = "../websocket" } lemmy_websocket = { path = "../websocket" }
diesel = "1.4.5" diesel = "1.4.7"
activitystreams = "0.7.0-alpha.11" activitystreams = "0.7.0-alpha.11"
activitystreams-ext = "0.1.0-alpha.2" activitystreams-ext = "0.1.0-alpha.2"
bcrypt = "0.9.0" bcrypt = "0.10.0"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }
serde_json = { version = "1.0.61", features = ["preserve_order"] } serde_json = { version = "1.0.64", features = ["preserve_order"] }
serde = { version = "1.0.123", features = ["derive"] } serde = { version = "1.0.126", features = ["derive"] }
actix = "0.10.0" actix = "0.12.0"
actix-web = { version = "3.3.2", default-features = false } actix-web = { version = "4.0.0-beta.8", default-features = false }
actix-rt = { version = "1.1.1", default-features = false } actix-rt = { version = "2.2.0", default-features = false }
awc = { version = "2.0.3", default-features = false } awc = { version = "3.0.0-beta.7", default-features = false }
log = "0.4.14" log = "0.4.14"
rand = "0.8.3" rand = "0.8.4"
strum = { version = "0.21", features = ["derive"] } strum = "0.21.0"
strum_macros = "0.21" strum_macros = "0.21.1"
url = { version = "2.2.1", features = ["serde"] } url = { version = "2.2.2", features = ["serde"] }
percent-encoding = "2.1.0" percent-encoding = "2.1.0"
openssl = "0.10.32" openssl = "0.10.35"
http = "0.2.3" http = "0.2.4"
http-signature-normalization-actix = { version = "0.4.1", default-features = false, features = ["sha-2"] } http-signature-normalization-actix = { version = "0.5.0-beta.6", default-features = false, features = ["sha-2"] }
http-signature-normalization-reqwest = { version = "0.1.3", default-features = false, features = ["sha-2"] } http-signature-normalization-reqwest = { version = "0.2.0", default-features = false, features = ["sha-2"] }
base64 = "0.13.0" base64 = "0.13.0"
tokio = "0.3.6" tokio = "1.8.0"
futures = "0.3.12" futures = "0.3.15"
itertools = "0.10.0" itertools = "0.10.1"
sha2 = "0.9.3" sha2 = "0.9.5"
async-trait = "0.1.42" async-trait = "0.1.50"
anyhow = "1.0.38" anyhow = "1.0.41"
thiserror = "1.0.23" thiserror = "1.0.26"
backtrace = "0.3.56" backtrace = "0.3.60"

View file

@ -11,19 +11,19 @@ doctest = false
[dependencies] [dependencies]
lemmy_utils = { path = "../utils" } lemmy_utils = { path = "../utils" }
lemmy_db_schema = { path = "../db_schema" } lemmy_db_schema = { path = "../db_schema" }
diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] } diesel = { version = "1.4.7", features = ["postgres","chrono","r2d2","serde_json"] }
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.126", features = ["derive"] }
serde_json = { version = "1.0.61", features = ["preserve_order"] } serde_json = { version = "1.0.64", features = ["preserve_order"] }
strum = "0.20.0" strum = "0.21.0"
strum_macros = "0.20.1" strum_macros = "0.21.1"
log = "0.4.14" log = "0.4.14"
sha2 = "0.9.3" sha2 = "0.9.5"
url = { version = "2.2.1", features = ["serde"] } url = { version = "2.2.2", features = ["serde"] }
lazy_static = "1.4.0" lazy_static = "1.4.0"
regex = "1.4.3" regex = "1.5.4"
bcrypt = "0.9.0" bcrypt = "0.10.0"
[dev-dependencies] [dev-dependencies]
serial_test = "0.5.1" serial_test = "0.5.1"

View file

@ -7,10 +7,10 @@ edition = "2018"
doctest = false doctest = false
[dependencies] [dependencies]
diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] } diesel = { version = "1.4.7", features = ["postgres","chrono","r2d2","serde_json"] }
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.126", features = ["derive"] }
serde_json = { version = "1.0.61", features = ["preserve_order"] } serde_json = { version = "1.0.64", features = ["preserve_order"] }
log = "0.4.14" log = "0.4.14"
url = { version = "2.2.1", features = ["serde"] } url = { version = "2.2.2", features = ["serde"] }
diesel-derive-newtype = "0.1" diesel-derive-newtype = "0.1.2"

View file

@ -9,10 +9,10 @@ doctest = false
[dependencies] [dependencies]
lemmy_db_queries = { path = "../db_queries" } lemmy_db_queries = { path = "../db_queries" }
lemmy_db_schema = { path = "../db_schema" } lemmy_db_schema = { path = "../db_schema" }
diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] } diesel = { version = "1.4.7", features = ["postgres","chrono","r2d2","serde_json"] }
serde = { version = "1.0.123", features = ["derive"] } serde = { version = "1.0.126", features = ["derive"] }
log = "0.4.14" log = "0.4.14"
url = "2.2.1" url = "2.2.2"
[dev-dependencies] [dev-dependencies]
serial_test = "0.5.1" serial_test = "0.5.1"

View file

@ -9,5 +9,5 @@ doctest = false
[dependencies] [dependencies]
lemmy_db_queries = { path = "../db_queries" } lemmy_db_queries = { path = "../db_queries" }
lemmy_db_schema = { path = "../db_schema" } lemmy_db_schema = { path = "../db_schema" }
diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] } diesel = { version = "1.4.7", features = ["postgres","chrono","r2d2","serde_json"] }
serde = { version = "1.0.123", features = ["derive"] } serde = { version = "1.0.126", features = ["derive"] }

View file

@ -9,5 +9,5 @@ doctest = false
[dependencies] [dependencies]
lemmy_db_queries = { path = "../db_queries" } lemmy_db_queries = { path = "../db_queries" }
lemmy_db_schema = { path = "../db_schema" } lemmy_db_schema = { path = "../db_schema" }
diesel = { version = "1.4.5", features = ["postgres","chrono","r2d2","serde_json"] } diesel = { version = "1.4.7", features = ["postgres","chrono","r2d2","serde_json"] }
serde = { version = "1.0.123", features = ["derive"] } serde = { version = "1.0.126", features = ["derive"] }

View file

@ -14,17 +14,17 @@ lemmy_db_views = { path = "../db_views" }
lemmy_db_views_actor = { path = "../db_views_actor" } lemmy_db_views_actor = { path = "../db_views_actor" }
lemmy_db_schema = { path = "../db_schema" } lemmy_db_schema = { path = "../db_schema" }
lemmy_api_common = { path = "../api_common" } lemmy_api_common = { path = "../api_common" }
diesel = "1.4.5" diesel = "1.4.7"
actix = "0.10.0" actix = "0.12.0"
actix-web = { version = "3.3.2", default-features = false, features = ["rustls"] } actix-web = { version = "4.0.0-beta.8", default-features = false, features = ["rustls"] }
actix-web-actors = { version = "3.0.0", default-features = false } actix-web-actors = { version = "4.0.0-beta.6", default-features = false }
sha2 = "0.9.3" sha2 = "0.9.5"
log = "0.4.14" log = "0.4.14"
anyhow = "1.0.38" anyhow = "1.0.41"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }
rss = "1.10.0" rss = "1.10.0"
serde = { version = "1.0.123", features = ["derive"] } serde = { version = "1.0.126", features = ["derive"] }
awc = { version = "2.0.3", default-features = false } awc = { version = "3.0.0-beta.7", default-features = false }
url = { version = "2.2.1", features = ["serde"] } url = { version = "2.2.2", features = ["serde"] }
strum = "0.20.0" strum = "0.21.0"
lazy_static = "1.4.0" lazy_static = "1.4.0"

View file

@ -124,12 +124,15 @@ async fn get_feed_data(
} }
async fn get_feed( async fn get_feed(
web::Path((req_type, param)): web::Path<(String, String)>, req: HttpRequest,
info: web::Query<Params>, info: web::Query<Params>,
context: web::Data<LemmyContext>, context: web::Data<LemmyContext>,
) -> Result<HttpResponse, Error> { ) -> Result<HttpResponse, Error> {
let sort_type = get_sort_type(info).map_err(ErrorBadRequest)?; let sort_type = get_sort_type(info).map_err(ErrorBadRequest)?;
let req_type: String = req.match_info().get("type").unwrap_or("none").parse()?;
let param: String = req.match_info().get("name").unwrap_or("none").parse()?;
let request_type = match req_type.as_str() { let request_type = match req_type.as_str() {
"u" => RequestType::User, "u" => RequestType::User,
"c" => RequestType::Community, "c" => RequestType::Community,

View file

@ -1,8 +1,8 @@
use actix::clock::Duration; use actix_web::{body::BodyStream, http::StatusCode, web::Data, *};
use actix_web::{body::BodyStream, http::StatusCode, *};
use awc::Client; use awc::Client;
use lemmy_utils::{claims::Claims, rate_limit::RateLimit, settings::structs::Settings}; use lemmy_utils::{claims::Claims, rate_limit::RateLimit, settings::structs::Settings};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::time::Duration;
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) { pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
let client = Client::builder() let client = Client::builder()
@ -11,7 +11,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
.finish(); .finish();
cfg cfg
.data(client) .app_data(Data::new(client))
.service( .service(
web::resource("/pictrs/image") web::resource("/pictrs/image")
.wrap(rate_limit.image()) .wrap(rate_limit.image())
@ -60,12 +60,15 @@ async fn upload(
); );
if let Some(addr) = req.head().peer_addr { if let Some(addr) = req.head().peer_addr {
client_req = client_req.header("X-Forwarded-For", addr.to_string()) client_req = client_req.insert_header(("X-Forwarded-For", addr.to_string()))
}; };
let mut res = client_req.send_stream(body).await?; let mut res = client_req
.send_stream(body)
.await
.map_err(error::ErrorBadRequest)?;
let images = res.json::<Images>().await?; let images = res.json::<Images>().await.map_err(error::ErrorBadRequest)?;
Ok(HttpResponse::build(res.status()).json(images)) Ok(HttpResponse::build(res.status()).json(images))
} }
@ -109,10 +112,14 @@ async fn image(
let mut client_req = client.request_from(url, req.head()); let mut client_req = client.request_from(url, req.head());
if let Some(addr) = req.head().peer_addr { if let Some(addr) = req.head().peer_addr {
client_req = client_req.header("X-Forwarded-For", addr.to_string()) client_req = client_req.insert_header(("X-Forwarded-For", addr.to_string()))
}; };
let res = client_req.no_decompress().send().await?; let res = client_req
.no_decompress()
.send()
.await
.map_err(error::ErrorBadRequest)?;
if res.status() == StatusCode::NOT_FOUND { if res.status() == StatusCode::NOT_FOUND {
return Ok(HttpResponse::NotFound().finish()); return Ok(HttpResponse::NotFound().finish());
@ -121,7 +128,7 @@ async fn image(
let mut client_res = HttpResponse::build(res.status()); let mut client_res = HttpResponse::build(res.status());
for (name, value) in res.headers().iter().filter(|(h, _)| *h != "connection") { for (name, value) in res.headers().iter().filter(|(h, _)| *h != "connection") {
client_res.header(name.clone(), value.clone()); client_res.insert_header((name.clone(), value.clone()));
} }
Ok(client_res.body(BodyStream::new(res))) Ok(client_res.body(BodyStream::new(res)))
@ -144,10 +151,14 @@ async fn delete(
let mut client_req = client.request_from(url, req.head()); let mut client_req = client.request_from(url, req.head());
if let Some(addr) = req.head().peer_addr { if let Some(addr) = req.head().peer_addr {
client_req = client_req.header("X-Forwarded-For", addr.to_string()) client_req = client_req.insert_header(("X-Forwarded-For", addr.to_string()))
}; };
let res = client_req.no_decompress().send().await?; let res = client_req
.no_decompress()
.send()
.await
.map_err(error::ErrorBadRequest)?;
Ok(HttpResponse::build(res.status()).body(BodyStream::new(res))) Ok(HttpResponse::build(res.status()).body(BodyStream::new(res)))
} }

View file

@ -9,31 +9,31 @@ path = "src/lib.rs"
doctest = false doctest = false
[dependencies] [dependencies]
regex = "1.4.3" regex = "1.5.4"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }
lettre = "0.10.0-alpha.5" lettre = "0.10.0-rc.3"
log = "0.4.14" log = "0.4.14"
itertools = "0.10.0" itertools = "0.10.1"
rand = "0.8.3" rand = "0.8.4"
percent-encoding = "2.1.0" percent-encoding = "2.1.0"
serde = { version = "1.0.123", features = ["derive"] } serde = { version = "1.0.126", features = ["derive"] }
serde_json = { version = "1.0.61", features = ["preserve_order"] } serde_json = { version = "1.0.64", features = ["preserve_order"] }
thiserror = "1.0.26" thiserror = "1.0.26"
comrak = { version = "0.9.0", default-features = false } comrak = { version = "0.10.1", default-features = false }
lazy_static = "1.4.0" lazy_static = "1.4.0"
openssl = "0.10.32" openssl = "0.10.35"
url = { version = "2.2.1", features = ["serde"] } url = { version = "2.2.2", features = ["serde"] }
actix-web = { version = "3.3.2", default-features = false, features = ["rustls"] } actix-web = { version = "4.0.0-beta.8", default-features = false, features = ["rustls"] }
actix-rt = { version = "1.1.1", default-features = false } actix-rt = { version = "2.2.0", default-features = false }
anyhow = "1.0.38" anyhow = "1.0.41"
reqwest = { version = "0.10.10", features = ["json"] } reqwest = { version = "0.11.4", features = ["json"] }
tokio = { version = "0.3.6", features = ["sync"] } tokio = { version = "1.8.0", features = ["sync"] }
strum = "0.20.0" strum = "0.21.0"
strum_macros = "0.20.1" strum_macros = "0.21.1"
futures = "0.3.12" futures = "0.3.15"
diesel = "1.4.5" diesel = "1.4.7"
http = "0.2.3" http = "0.2.4"
jsonwebtoken = "7.2.0" jsonwebtoken = "7.2.0"
deser-hjson = "0.1.12" deser-hjson = "1.0.1"
merge = "0.1.0" merge = "0.1.0"
envy = "0.4.2" envy = "0.4.2"

View file

@ -49,21 +49,13 @@ pub fn send_email(
MultiPart::alternative() MultiPart::alternative()
.singlepart( .singlepart(
SinglePart::builder() SinglePart::builder()
.header(header::ContentType( .header(header::ContentType::TEXT_PLAIN)
"text/plain; charset=utf8"
.parse()
.expect("email could not parse header"),
))
.body(html.to_string()), .body(html.to_string()),
) )
.multipart( .multipart(
MultiPart::related().singlepart( MultiPart::related().singlepart(
SinglePart::builder() SinglePart::builder()
.header(header::ContentType( .header(header::ContentType::TEXT_HTML)
"text/html; charset=utf8"
.parse()
.expect("email could not parse header"),
))
.body(html.to_string()), .body(html.to_string()),
), ),
), ),

View file

@ -154,12 +154,11 @@ impl RateLimited {
} }
} }
impl<S> Transform<S> for RateLimited impl<S> Transform<S, ServiceRequest> for RateLimited
where where
S: Service<Request = ServiceRequest, Response = ServiceResponse, Error = actix_web::Error>, S: Service<ServiceRequest, Response = ServiceResponse, Error = actix_web::Error>,
S::Future: 'static, S::Future: 'static,
{ {
type Request = S::Request;
type Response = S::Response; type Response = S::Response;
type Error = actix_web::Error; type Error = actix_web::Error;
type InitError = (); type InitError = ();
@ -176,21 +175,20 @@ where
type FutResult<T, E> = dyn Future<Output = Result<T, E>>; type FutResult<T, E> = dyn Future<Output = Result<T, E>>;
impl<S> Service for RateLimitedMiddleware<S> impl<S> Service<ServiceRequest> for RateLimitedMiddleware<S>
where where
S: Service<Request = ServiceRequest, Response = ServiceResponse, Error = actix_web::Error>, S: Service<ServiceRequest, Response = ServiceResponse, Error = actix_web::Error>,
S::Future: 'static, S::Future: 'static,
{ {
type Request = S::Request;
type Response = S::Response; type Response = S::Response;
type Error = actix_web::Error; type Error = actix_web::Error;
type Future = Pin<Box<FutResult<Self::Response, Self::Error>>>; type Future = Pin<Box<FutResult<Self::Response, Self::Error>>>;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.service.poll_ready(cx) self.service.poll_ready(cx)
} }
fn call(&mut self, req: S::Request) -> Self::Future { fn call(&self, req: ServiceRequest) -> Self::Future {
let ip_addr = get_ip(&req.connection_info()); let ip_addr = get_ip(&req.connection_info());
let fut = self let fut = self

View file

@ -13,18 +13,18 @@ lemmy_utils = { path = "../utils" }
lemmy_api_common = { path = "../api_common" } lemmy_api_common = { path = "../api_common" }
lemmy_db_queries = { path = "../db_queries" } lemmy_db_queries = { path = "../db_queries" }
lemmy_db_schema = { path = "../db_schema" } lemmy_db_schema = { path = "../db_schema" }
reqwest = { version = "0.10.10", features = ["json"] } reqwest = { version = "0.11.4", features = ["json"] }
log = "0.4.14" log = "0.4.14"
rand = "0.8.3" rand = "0.8.4"
serde = { version = "1.0.123", features = ["derive"] } serde = { version = "1.0.126", features = ["derive"] }
serde_json = { version = "1.0.61", features = ["preserve_order"] } serde_json = { version = "1.0.64", features = ["preserve_order"] }
actix = "0.10.0" actix = "0.12.0"
anyhow = "1.0.38" anyhow = "1.0.41"
diesel = "1.4.5" diesel = "1.4.7"
background-jobs = "0.8.0" background-jobs = "0.9.0"
tokio = "0.3.6" tokio = "1.8.0"
strum = "0.20.0" strum = "0.21.0"
strum_macros = "0.20.1" strum_macros = "0.21.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 = { version = "4.0.0-beta.8", default-features = false, features = ["rustls"] }
actix-web-actors = { version = "3.0.0", default-features = false } actix-web-actors = { version = "4.0.0-beta.6", default-features = false }

View file

@ -29,6 +29,7 @@ use serde::Serialize;
use serde_json::Value; use serde_json::Value;
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
future::Future,
str::FromStr, str::FromStr,
}; };
use tokio::macros::support::Pin; use tokio::macros::support::Pin;

View file

@ -2,7 +2,7 @@
extern crate diesel_migrations; extern crate diesel_migrations;
use actix::prelude::*; use actix::prelude::*;
use actix_web::*; use actix_web::{web::Data, *};
use diesel::{ use diesel::{
r2d2::{ConnectionManager, Pool}, r2d2::{ConnectionManager, Pool},
PgConnection, PgConnection,
@ -88,7 +88,7 @@ async fn main() -> Result<(), LemmyError> {
let rate_limiter = rate_limiter.clone(); let rate_limiter = rate_limiter.clone();
App::new() App::new()
.wrap(middleware::Logger::default()) .wrap(middleware::Logger::default())
.data(context) .app_data(Data::new(context))
// The routes // The routes
.configure(|cfg| api_routes::config(cfg, &rate_limiter)) .configure(|cfg| api_routes::config(cfg, &rate_limiter))
.configure(lemmy_apub_receive::routes::config) .configure(lemmy_apub_receive::routes::config)