Merge branch 'main' into invite_instances

invite_instances
Dessalines 2021-12-06 09:52:41 -05:00
commit aa578835a7
45 changed files with 265 additions and 107 deletions

View File

@ -80,7 +80,7 @@ steps:
- name: publish release docker manifest - name: publish release docker manifest
image: plugins/manifest image: plugins/manifest
settings: settings:
username: username:
from_secret: docker_username from_secret: docker_username
password: password:
@ -95,6 +95,23 @@ steps:
ref: ref:
- refs/tags/* - refs/tags/*
- name: publish latest release docker manifest
image: plugins/manifest
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
target: "dessalines/lemmy:latest"
template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
platforms:
- linux/amd64
- linux/arm64
ignore_missing: true
when:
ref:
- refs/tags/*
# using https://github.com/pksunkara/cargo-workspaces # using https://github.com/pksunkara/cargo-workspaces
- name: publish to crates.io - name: publish to crates.io
image: rustlang/rust:nightly image: rustlang/rust:nightly
@ -192,7 +209,7 @@ steps:
- name: publish release docker manifest - name: publish release docker manifest
image: plugins/manifest image: plugins/manifest
settings: settings:
username: username:
from_secret: docker_username from_secret: docker_username
password: password:
@ -207,6 +224,23 @@ steps:
ref: ref:
- refs/tags/* - refs/tags/*
- name: publish latest release docker manifest
image: plugins/manifest
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
target: "dessalines/lemmy:latest"
template: "dessalines/lemmy:${DRONE_TAG}-OS-ARCH"
platforms:
- linux/amd64
- linux/arm64
ignore_missing: true
when:
ref:
- refs/tags/*
# TODO temporarily disable arm tests # TODO temporarily disable arm tests
# services: # services:
# - name: database # - name: database

28
Cargo.lock generated
View File

@ -1722,7 +1722,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "lemmy_api" name = "lemmy_api"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"actix", "actix",
"actix-rt", "actix-rt",
@ -1765,7 +1765,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_api_common" name = "lemmy_api_common"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"chrono", "chrono",
@ -1782,7 +1782,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_api_crud" name = "lemmy_api_crud"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"actix", "actix",
"actix-rt", "actix-rt",
@ -1826,7 +1826,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_apub" name = "lemmy_apub"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"activitystreams-kinds", "activitystreams-kinds",
"actix", "actix",
@ -1872,7 +1872,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_apub_lib" name = "lemmy_apub_lib"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"activitystreams", "activitystreams",
"actix-web", "actix-web",
@ -1898,7 +1898,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_apub_lib_derive" name = "lemmy_apub_lib_derive"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"proc-macro2 1.0.32", "proc-macro2 1.0.32",
"quote 1.0.10", "quote 1.0.10",
@ -1908,7 +1908,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_db_schema" name = "lemmy_db_schema"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"bcrypt", "bcrypt",
"chrono", "chrono",
@ -1930,7 +1930,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_db_views" name = "lemmy_db_views"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"diesel", "diesel",
"lemmy_db_schema", "lemmy_db_schema",
@ -1942,7 +1942,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_db_views_actor" name = "lemmy_db_views_actor"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"diesel", "diesel",
"lemmy_db_schema", "lemmy_db_schema",
@ -1951,7 +1951,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_db_views_moderator" name = "lemmy_db_views_moderator"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"diesel", "diesel",
"lemmy_db_schema", "lemmy_db_schema",
@ -1960,7 +1960,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_routes" name = "lemmy_routes"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"actix", "actix",
"actix-http", "actix-http",
@ -1987,7 +1987,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_server" name = "lemmy_server"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"activitystreams", "activitystreams",
"actix", "actix",
@ -2029,7 +2029,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_utils" name = "lemmy_utils"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"actix-rt", "actix-rt",
"actix-web", "actix-web",
@ -2066,7 +2066,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_websocket" name = "lemmy_websocket"
version = "0.14.3" version = "0.14.4-rc.4"
dependencies = [ dependencies = [
"actix", "actix",
"actix-web", "actix-web",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_server" name = "lemmy_server"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"
@ -31,18 +31,18 @@ members = [
] ]
[dependencies] [dependencies]
lemmy_api = { version = "=0.14.3", path = "./crates/api" } lemmy_api = { version = "=0.14.4-rc.4", path = "./crates/api" }
lemmy_api_crud = { version = "=0.14.3", path = "./crates/api_crud" } lemmy_api_crud = { version = "=0.14.4-rc.4", path = "./crates/api_crud" }
lemmy_apub = { version = "=0.14.3", path = "./crates/apub" } lemmy_apub = { version = "=0.14.4-rc.4", path = "./crates/apub" }
lemmy_apub_lib = { version = "=0.14.3", path = "./crates/apub_lib" } lemmy_apub_lib = { version = "=0.14.4-rc.4", path = "./crates/apub_lib" }
lemmy_utils = { version = "=0.14.3", path = "./crates/utils" } lemmy_utils = { version = "=0.14.4-rc.4", path = "./crates/utils" }
lemmy_db_schema = { version = "=0.14.3", path = "./crates/db_schema" } lemmy_db_schema = { version = "=0.14.4-rc.4", path = "./crates/db_schema" }
lemmy_db_views = { version = "=0.14.3", path = "./crates/db_views" } lemmy_db_views = { version = "=0.14.4-rc.4", path = "./crates/db_views" }
lemmy_db_views_moderator = { version = "=0.14.3", path = "./crates/db_views_moderator" } lemmy_db_views_moderator = { version = "=0.14.4-rc.4", path = "./crates/db_views_moderator" }
lemmy_db_views_actor = { version = "=0.14.3", path = "./crates/db_views_actor" } lemmy_db_views_actor = { version = "=0.14.4-rc.4", path = "./crates/db_views_actor" }
lemmy_api_common = { version = "=0.14.3", path = "crates/api_common" } lemmy_api_common = { version = "=0.14.4-rc.4", path = "crates/api_common" }
lemmy_websocket = { version = "=0.14.3", path = "./crates/websocket" } lemmy_websocket = { version = "=0.14.4-rc.4", path = "./crates/websocket" }
lemmy_routes = { version = "=0.14.3", path = "./crates/routes" } lemmy_routes = { version = "=0.14.4-rc.4", path = "./crates/routes" }
diesel = "1.4.8" diesel = "1.4.8"
diesel_migrations = "1.4.0" diesel_migrations = "1.4.0"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }

View File

@ -115,4 +115,6 @@
slur_filter: "(\bThis\b)|(\bis\b)|(\bsample\b)" slur_filter: "(\bThis\b)|(\bis\b)|(\bsample\b)"
# Maximum length of local community and user names # Maximum length of local community and user names
actor_name_max_length: 20 actor_name_max_length: 20
# Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object fetch through the search).
http_fetch_retry_limit: 25
} }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_api" name = "lemmy_api"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"
@ -13,15 +13,15 @@ path = "src/lib.rs"
doctest = false doctest = false
[dependencies] [dependencies]
lemmy_apub = { version = "=0.14.3", path = "../apub" } lemmy_apub = { version = "=0.14.4-rc.4", path = "../apub" }
lemmy_apub_lib = { version = "=0.14.3", path = "../apub_lib" } lemmy_apub_lib = { version = "=0.14.4-rc.4", path = "../apub_lib" }
lemmy_utils = { version = "=0.14.3", path = "../utils" } lemmy_utils = { version = "=0.14.4-rc.4", path = "../utils" }
lemmy_db_schema = { version = "=0.14.3", path = "../db_schema" } lemmy_db_schema = { version = "=0.14.4-rc.4", path = "../db_schema" }
lemmy_db_views = { version = "=0.14.3", path = "../db_views" } lemmy_db_views = { version = "=0.14.4-rc.4", path = "../db_views" }
lemmy_db_views_moderator = { version = "=0.14.3", path = "../db_views_moderator" } lemmy_db_views_moderator = { version = "=0.14.4-rc.4", path = "../db_views_moderator" }
lemmy_db_views_actor = { version = "=0.14.3", path = "../db_views_actor" } lemmy_db_views_actor = { version = "=0.14.4-rc.4", path = "../db_views_actor" }
lemmy_api_common = { version = "=0.14.3", path = "../api_common" } lemmy_api_common = { version = "=0.14.4-rc.4", path = "../api_common" }
lemmy_websocket = { version = "=0.14.3", path = "../websocket" } lemmy_websocket = { version = "=0.14.4-rc.4", path = "../websocket" }
diesel = "1.4.8" diesel = "1.4.8"
bcrypt = "0.10.1" bcrypt = "0.10.1"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_api_common" name = "lemmy_api_common"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"
@ -13,11 +13,11 @@ path = "src/lib.rs"
doctest = false doctest = false
[dependencies] [dependencies]
lemmy_db_views = { version = "=0.14.3", path = "../db_views" } lemmy_db_views = { version = "=0.14.4-rc.4", path = "../db_views" }
lemmy_db_views_moderator = { version = "=0.14.3", path = "../db_views_moderator" } lemmy_db_views_moderator = { version = "=0.14.4-rc.4", path = "../db_views_moderator" }
lemmy_db_views_actor = { version = "=0.14.3", path = "../db_views_actor" } lemmy_db_views_actor = { version = "=0.14.4-rc.4", path = "../db_views_actor" }
lemmy_db_schema = { version = "=0.14.3", path = "../db_schema" } lemmy_db_schema = { version = "=0.14.4-rc.4", path = "../db_schema" }
lemmy_utils = { version = "=0.14.3", path = "../utils" } lemmy_utils = { version = "=0.14.4-rc.4", path = "../utils" }
serde = { version = "1.0.130", features = ["derive"] } serde = { version = "1.0.130", features = ["derive"] }
diesel = "1.4.8" diesel = "1.4.8"
actix-web = { version = "4.0.0-beta.9", default-features = false, features = ["cookies"] } actix-web = { version = "4.0.0-beta.9", default-features = false, features = ["cookies"] }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_api_crud" name = "lemmy_api_crud"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"
@ -8,15 +8,15 @@ homepage = "https://join-lemmy.org/"
documentation = "https://join-lemmy.org/docs/en/index.html" documentation = "https://join-lemmy.org/docs/en/index.html"
[dependencies] [dependencies]
lemmy_apub = { version = "=0.14.3", path = "../apub" } lemmy_apub = { version = "=0.14.4-rc.4", path = "../apub" }
lemmy_apub_lib = { version = "=0.14.3", path = "../apub_lib" } lemmy_apub_lib = { version = "=0.14.4-rc.4", path = "../apub_lib" }
lemmy_utils = { version = "=0.14.3", path = "../utils" } lemmy_utils = { version = "=0.14.4-rc.4", path = "../utils" }
lemmy_db_schema = { version = "=0.14.3", path = "../db_schema" } lemmy_db_schema = { version = "=0.14.4-rc.4", path = "../db_schema" }
lemmy_db_views = { version = "=0.14.3", path = "../db_views" } lemmy_db_views = { version = "=0.14.4-rc.4", path = "../db_views" }
lemmy_db_views_moderator = { version = "=0.14.3", path = "../db_views_moderator" } lemmy_db_views_moderator = { version = "=0.14.4-rc.4", path = "../db_views_moderator" }
lemmy_db_views_actor = { version = "=0.14.3", path = "../db_views_actor" } lemmy_db_views_actor = { version = "=0.14.4-rc.4", path = "../db_views_actor" }
lemmy_api_common = { version = "=0.14.3", path = "../api_common" } lemmy_api_common = { version = "=0.14.4-rc.4", path = "../api_common" }
lemmy_websocket = { version = "=0.14.3", path = "../websocket" } lemmy_websocket = { version = "=0.14.4-rc.4", path = "../websocket" }
diesel = "1.4.8" diesel = "1.4.8"
bcrypt = "0.10.1" bcrypt = "0.10.1"
chrono = { version = "0.4.19", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_apub" name = "lemmy_apub"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"
@ -13,13 +13,13 @@ path = "src/lib.rs"
doctest = false doctest = false
[dependencies] [dependencies]
lemmy_utils = { version = "=0.14.3", path = "../utils" } lemmy_utils = { version = "=0.14.4-rc.4", path = "../utils" }
lemmy_apub_lib = { version = "=0.14.3", path = "../apub_lib" } lemmy_apub_lib = { version = "=0.14.4-rc.4", path = "../apub_lib" }
lemmy_db_schema = { version = "=0.14.3", path = "../db_schema" } lemmy_db_schema = { version = "=0.14.4-rc.4", path = "../db_schema" }
lemmy_db_views = { version = "=0.14.3", path = "../db_views" } lemmy_db_views = { version = "=0.14.4-rc.4", path = "../db_views" }
lemmy_db_views_actor = { version = "=0.14.3", path = "../db_views_actor" } lemmy_db_views_actor = { version = "=0.14.4-rc.4", path = "../db_views_actor" }
lemmy_api_common = { version = "=0.14.3", path = "../api_common" } lemmy_api_common = { version = "=0.14.4-rc.4", path = "../api_common" }
lemmy_websocket = { version = "=0.14.3", path = "../websocket" } lemmy_websocket = { version = "=0.14.4-rc.4", path = "../websocket" }
diesel = "1.4.8" diesel = "1.4.8"
activitystreams-kinds = "0.1.2" activitystreams-kinds = "0.1.2"
bcrypt = "0.10.1" bcrypt = "0.10.1"

View File

@ -0,0 +1,30 @@
{
"actor": "https://c.tide.tk/users/1",
"object": {
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://c.tide.tk/comments/52",
"type": "Note",
"mediaType": "text/html",
"source": {
"content": "test comment",
"mediaType": "text/markdown"
},
"attributedTo": "https://c.tide.tk/users/1",
"content": "<p>test comment</p>\n",
"published": "2021-09-16T01:20:27.558063+00:00",
"inReplyTo": "https://c.tide.tk/posts/51",
"to": "https://c.tide.tk/users/1",
"cc": [
"https://www.w3.org/ns/activitystreams#Public",
"https://c.tide.tk/communities/1"
]
},
"to": "https://c.tide.tk/users/1",
"cc": [
"https://www.w3.org/ns/activitystreams#Public",
"https://c.tide.tk/communities/1"
],
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://c.tide.tk/comments/52/create",
"type": "Create"
}

View File

@ -0,0 +1,20 @@
{
"actor": "https://b.tide.tk/apub/users/1",
"object": {
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://b.tide.tk/apub/posts/60",
"type": "Page",
"name": "test post from b",
"summary": "test post from b",
"to": "https://c.tide.tk/communities/1",
"cc": "https://www.w3.org/ns/activitystreams#Public",
"published": "2020-12-19T19:20:26.941381+00:00",
"attributedTo": "https://b.tide.tk/apub/users/1",
"url": "https://blog.twitter.com/engineering/en_us/a/2010/announcing-snowflake.html"
},
"to": "https://c.tide.tk/communities/1",
"cc": "https://www.w3.org/ns/activitystreams#Public",
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://b.tide.tk/apub/posts/60/create",
"type": "Create"
}

View File

@ -108,7 +108,15 @@ impl ActivityHandler for CreateOrUpdateComment {
request_counter: &mut i32, request_counter: &mut i32,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let comment = ApubComment::from_apub(self.object, context, request_counter).await?; let comment = ApubComment::from_apub(self.object, context, request_counter).await?;
let recipients = get_notif_recipients(&self.actor, &comment, context, request_counter).await?; let do_send_email = self.kind == CreateOrUpdateType::Create;
let recipients = get_notif_recipients(
&self.actor,
&comment,
do_send_email,
context,
request_counter,
)
.await?;
let notif_type = match self.kind { let notif_type = match self.kind {
CreateOrUpdateType::Create => UserOperationCrud::CreateComment, CreateOrUpdateType::Create => UserOperationCrud::CreateComment,
CreateOrUpdateType::Update => UserOperationCrud::EditComment, CreateOrUpdateType::Update => UserOperationCrud::EditComment,

View File

@ -14,6 +14,7 @@ pub mod create_or_update;
async fn get_notif_recipients( async fn get_notif_recipients(
actor: &ObjectId<ApubPerson>, actor: &ObjectId<ApubPerson>,
comment: &Comment, comment: &Comment,
do_send_email: bool,
context: &LemmyContext, context: &LemmyContext,
request_counter: &mut i32, request_counter: &mut i32,
) -> Result<Vec<LocalUserId>, LemmyError> { ) -> Result<Vec<LocalUserId>, LemmyError> {
@ -27,5 +28,5 @@ async fn get_notif_recipients(
// anyway. // anyway.
// TODO: for compatibility with other projects, it would be much better to read this from cc or tags // TODO: for compatibility with other projects, it would be much better to read this from cc or tags
let mentions = scrape_text_for_mentions(&comment.content); let mentions = scrape_text_for_mentions(&comment.content);
send_local_notifs(mentions, comment, &*actor, &post, true, context).await send_local_notifs(mentions, comment, &*actor, &post, do_send_email, context).await
} }

View File

@ -8,6 +8,7 @@ static CONTEXT: Lazy<Vec<serde_json::Value>> = Lazy::new(|| {
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub(crate) struct WithContext<T> { pub(crate) struct WithContext<T> {
#[serde(rename = "@context")] #[serde(rename = "@context")]
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
context: Vec<serde_json::Value>, context: Vec<serde_json::Value>,
#[serde(flatten)] #[serde(flatten)]
inner: T, inner: T,

View File

@ -81,6 +81,11 @@ where
); );
debug!("Fetching webfinger url: {}", &fetch_url); debug!("Fetching webfinger url: {}", &fetch_url);
*request_counter += 1;
if *request_counter > context.settings().http_fetch_retry_limit {
return Err(LemmyError::from(anyhow!("Request retry limit reached")));
}
let response = retry(|| context.client().get(&fetch_url).send()).await?; let response = retry(|| context.client().get(&fetch_url).send()).await?;
let res: WebfingerResponse = response let res: WebfingerResponse = response

View File

@ -3,6 +3,7 @@ use anyhow::{anyhow, Context};
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_db_schema::{newtypes::DbUrl, source::activity::Activity, DbPool}; use lemmy_db_schema::{newtypes::DbUrl, source::activity::Activity, DbPool};
use lemmy_utils::{location_info, settings::structs::Settings, LemmyError}; use lemmy_utils::{location_info, settings::structs::Settings, LemmyError};
use serde::{Deserialize, Deserializer};
use std::net::IpAddr; use std::net::IpAddr;
use url::{ParseError, Url}; use url::{ParseError, Url};
@ -85,6 +86,25 @@ pub(crate) fn check_is_apub_id_valid(
Ok(()) Ok(())
} }
pub(crate) fn deserialize_one_or_many<'de, T, D>(deserializer: D) -> Result<Vec<T>, D::Error>
where
T: Deserialize<'de>,
D: Deserializer<'de>,
{
#[derive(Deserialize)]
#[serde(untagged)]
enum OneOrMany<T> {
One(T),
Many(Vec<T>),
}
let result: OneOrMany<T> = Deserialize::deserialize(deserializer)?;
Ok(match result {
OneOrMany::Many(list) => list,
OneOrMany::One(value) => vec![value],
})
}
pub enum EndpointType { pub enum EndpointType {
Community, Community,
Person, Person,

View File

@ -8,9 +8,11 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct AddMod { pub struct AddMod {
pub(crate) actor: ObjectId<ApubPerson>, pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
pub(crate) object: ObjectId<ApubPerson>, pub(crate) object: ObjectId<ApubPerson>,
pub(crate) target: Url, pub(crate) target: Url,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>, pub(crate) cc: Vec<Url>,
#[serde(rename = "type")] #[serde(rename = "type")]
pub(crate) kind: AddType, pub(crate) kind: AddType,

View File

@ -12,8 +12,10 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct AnnounceActivity { pub struct AnnounceActivity {
pub(crate) actor: ObjectId<ApubCommunity>, pub(crate) actor: ObjectId<ApubCommunity>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
pub(crate) object: AnnouncableActivities, pub(crate) object: AnnouncableActivities,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>, pub(crate) cc: Vec<Url>,
#[serde(rename = "type")] #[serde(rename = "type")]
pub(crate) kind: AnnounceType, pub(crate) kind: AnnounceType,

View File

@ -11,8 +11,10 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct BlockUserFromCommunity { pub struct BlockUserFromCommunity {
pub(crate) actor: ObjectId<ApubPerson>, pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
pub(crate) object: ObjectId<ApubPerson>, pub(crate) object: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>, pub(crate) cc: Vec<Url>,
pub(crate) target: ObjectId<ApubCommunity>, pub(crate) target: ObjectId<ApubCommunity>,
#[serde(rename = "type")] #[serde(rename = "type")]

View File

@ -8,8 +8,10 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct RemoveMod { pub struct RemoveMod {
pub(crate) actor: ObjectId<ApubPerson>, pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
pub(crate) object: ObjectId<ApubPerson>, pub(crate) object: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>, pub(crate) cc: Vec<Url>,
#[serde(rename = "type")] #[serde(rename = "type")]
pub(crate) kind: RemoveType, pub(crate) kind: RemoveType,

View File

@ -11,8 +11,10 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct UndoBlockUserFromCommunity { pub struct UndoBlockUserFromCommunity {
pub(crate) actor: ObjectId<ApubPerson>, pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
pub(crate) object: BlockUserFromCommunity, pub(crate) object: BlockUserFromCommunity,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>, pub(crate) cc: Vec<Url>,
#[serde(rename = "type")] #[serde(rename = "type")]
pub(crate) kind: UndoType, pub(crate) kind: UndoType,

View File

@ -13,9 +13,11 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct UpdateCommunity { pub struct UpdateCommunity {
pub(crate) actor: ObjectId<ApubPerson>, pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
// TODO: would be nice to use a separate struct here, which only contains the fields updated here // TODO: would be nice to use a separate struct here, which only contains the fields updated here
pub(crate) object: Box<Group>, pub(crate) object: Box<Group>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>, pub(crate) cc: Vec<Url>,
#[serde(rename = "type")] #[serde(rename = "type")]
pub(crate) kind: UpdateType, pub(crate) kind: UpdateType,

View File

@ -11,8 +11,10 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct CreateOrUpdateComment { pub struct CreateOrUpdateComment {
pub(crate) actor: ObjectId<ApubPerson>, pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
pub(crate) object: Note, pub(crate) object: Note,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>, pub(crate) cc: Vec<Url>,
#[serde(default)] #[serde(default)]
pub(crate) tag: Vec<Mention>, pub(crate) tag: Vec<Mention>,

View File

@ -26,5 +26,8 @@ mod tests {
file_to_json_object::<CreateOrUpdateComment>("assets/pleroma/activities/create_note.json"); file_to_json_object::<CreateOrUpdateComment>("assets/pleroma/activities/create_note.json");
file_to_json_object::<CreateOrUpdateComment>("assets/smithereen/activities/create_note.json"); file_to_json_object::<CreateOrUpdateComment>("assets/smithereen/activities/create_note.json");
file_to_json_object::<CreateOrUpdateComment>("assets/mastodon/activities/create_note.json"); file_to_json_object::<CreateOrUpdateComment>("assets/mastodon/activities/create_note.json");
file_to_json_object::<CreateOrUpdatePost>("assets/lotide/activities/create_page.json");
file_to_json_object::<CreateOrUpdateComment>("assets/lotide/activities/create_note_reply.json");
} }
} }

View File

@ -10,8 +10,10 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct CreateOrUpdatePost { pub struct CreateOrUpdatePost {
pub(crate) actor: ObjectId<ApubPerson>, pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
pub(crate) object: Page, pub(crate) object: Page,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>, pub(crate) cc: Vec<Url>,
#[serde(rename = "type")] #[serde(rename = "type")]
pub(crate) kind: CreateOrUpdateType, pub(crate) kind: CreateOrUpdateType,

View File

@ -13,6 +13,7 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Delete { pub struct Delete {
pub(crate) actor: ObjectId<ApubPerson>, pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
pub(crate) object: Tombstone, pub(crate) object: Tombstone,
#[serde(rename = "type")] #[serde(rename = "type")]

View File

@ -11,8 +11,10 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct UndoDelete { pub struct UndoDelete {
pub(crate) actor: ObjectId<ApubPerson>, pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
pub(crate) object: Delete, pub(crate) object: Delete,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>, pub(crate) cc: Vec<Url>,
#[serde(rename = "type")] #[serde(rename = "type")]
pub(crate) kind: UndoType, pub(crate) kind: UndoType,

View File

@ -11,8 +11,10 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct UndoVote { pub struct UndoVote {
pub(crate) actor: ObjectId<ApubPerson>, pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
pub(crate) object: Vote, pub(crate) object: Vote,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>, pub(crate) cc: Vec<Url>,
#[serde(rename = "type")] #[serde(rename = "type")]
pub(crate) kind: UndoType, pub(crate) kind: UndoType,

View File

@ -15,8 +15,10 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Vote { pub struct Vote {
pub(crate) actor: ObjectId<ApubPerson>, pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
pub(crate) object: ObjectId<PostOrComment>, pub(crate) object: ObjectId<PostOrComment>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>, pub(crate) cc: Vec<Url>,
#[serde(rename = "type")] #[serde(rename = "type")]
pub(crate) kind: VoteType, pub(crate) kind: VoteType,

View File

@ -23,8 +23,10 @@ pub struct Note {
pub(crate) r#type: NoteType, pub(crate) r#type: NoteType,
pub(crate) id: ObjectId<ApubComment>, pub(crate) id: ObjectId<ApubComment>,
pub(crate) attributed_to: ObjectId<ApubPerson>, pub(crate) attributed_to: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
#[serde(default)] #[serde(default)]
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>, pub(crate) cc: Vec<Url>,
pub(crate) content: String, pub(crate) content: String,
pub(crate) media_type: Option<MediaTypeHtml>, pub(crate) media_type: Option<MediaTypeHtml>,

View File

@ -24,8 +24,10 @@ pub struct Page {
pub(crate) r#type: PageType, pub(crate) r#type: PageType,
pub(crate) id: ObjectId<ApubPost>, pub(crate) id: ObjectId<ApubPost>,
pub(crate) attributed_to: ObjectId<ApubPerson>, pub(crate) attributed_to: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>, pub(crate) to: Vec<Url>,
#[serde(default)] #[serde(default)]
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>, pub(crate) cc: Vec<Url>,
pub(crate) name: String, pub(crate) name: String,
pub(crate) content: Option<String>, pub(crate) content: Option<String>,

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_apub_lib" name = "lemmy_apub_lib"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"
@ -8,8 +8,8 @@ homepage = "https://join-lemmy.org/"
documentation = "https://join-lemmy.org/docs/en/index.html" documentation = "https://join-lemmy.org/docs/en/index.html"
[dependencies] [dependencies]
lemmy_utils = { version = "=0.14.3", path = "../utils" } lemmy_utils = { version = "=0.14.4-rc.4", path = "../utils" }
lemmy_apub_lib_derive = { version = "=0.14.3", path = "../apub_lib_derive" } lemmy_apub_lib_derive = { version = "=0.14.4-rc.4", path = "../apub_lib_derive" }
activitystreams = "0.7.0-alpha.11" activitystreams = "0.7.0-alpha.11"
serde = { version = "1.0.130", features = ["derive"] } serde = { version = "1.0.130", features = ["derive"] }
async-trait = "0.1.51" async-trait = "0.1.51"

View File

@ -18,10 +18,6 @@ use std::{
use tracing::info; use tracing::info;
use url::Url; use url::Url;
/// Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object
/// fetch through the search). This should be configurable.
static REQUEST_LIMIT: i32 = 25;
static CLIENT: Lazy<Client> = Lazy::new(|| { static CLIENT: Lazy<Client> = Lazy::new(|| {
Client::builder() Client::builder()
.user_agent(build_user_agent(&Settings::get())) .user_agent(build_user_agent(&Settings::get()))
@ -119,8 +115,8 @@ where
info!("Fetching remote object {}", self.to_string()); info!("Fetching remote object {}", self.to_string());
*request_counter += 1; *request_counter += 1;
if *request_counter > REQUEST_LIMIT { if *request_counter > Settings::get().http_fetch_retry_limit {
return Err(LemmyError::from(anyhow!("Request limit reached"))); return Err(LemmyError::from(anyhow!("Request retry limit reached")));
} }
let res = retry(|| { let res = retry(|| {

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_apub_lib_derive" name = "lemmy_apub_lib_derive"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_db_schema" name = "lemmy_db_schema"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"
@ -11,8 +11,8 @@ documentation = "https://join-lemmy.org/docs/en/index.html"
doctest = false doctest = false
[dependencies] [dependencies]
lemmy_utils = { version = "=0.14.3", path = "../utils" } lemmy_utils = { version = "=0.14.4-rc.4", path = "../utils" }
lemmy_apub_lib = { version = "=0.14.3", path = "../apub_lib" } lemmy_apub_lib = { version = "=0.14.4-rc.4", path = "../apub_lib" }
diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"] } diesel = { version = "1.4.8", 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"] }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_db_views" name = "lemmy_db_views"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"
@ -11,7 +11,7 @@ documentation = "https://join-lemmy.org/docs/en/index.html"
doctest = false doctest = false
[dependencies] [dependencies]
lemmy_db_schema = { version = "=0.14.3", path = "../db_schema" } lemmy_db_schema = { version = "=0.14.4-rc.4", path = "../db_schema" }
diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"] } diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"] }
serde = { version = "1.0.130", features = ["derive"] } serde = { version = "1.0.130", features = ["derive"] }
tracing = "0.1.29" tracing = "0.1.29"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_db_views_actor" name = "lemmy_db_views_actor"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"
@ -11,6 +11,6 @@ documentation = "https://join-lemmy.org/docs/en/index.html"
doctest = false doctest = false
[dependencies] [dependencies]
lemmy_db_schema = { version = "=0.14.3", path = "../db_schema" } lemmy_db_schema = { version = "=0.14.4-rc.4", path = "../db_schema" }
diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"] } diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"] }
serde = { version = "1.0.130", features = ["derive"] } serde = { version = "1.0.130", features = ["derive"] }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_db_views_moderator" name = "lemmy_db_views_moderator"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"
@ -11,6 +11,6 @@ documentation = "https://join-lemmy.org/docs/en/index.html"
doctest = false doctest = false
[dependencies] [dependencies]
lemmy_db_schema = { version = "=0.14.3", path = "../db_schema" } lemmy_db_schema = { version = "=0.14.4-rc.4", path = "../db_schema" }
diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"] } diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"] }
serde = { version = "1.0.130", features = ["derive"] } serde = { version = "1.0.130", features = ["derive"] }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_routes" name = "lemmy_routes"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"
@ -11,13 +11,13 @@ documentation = "https://join-lemmy.org/docs/en/index.html"
doctest = false doctest = false
[dependencies] [dependencies]
lemmy_utils = { version = "=0.14.3", path = "../utils" } lemmy_utils = { version = "=0.14.4-rc.4", path = "../utils" }
lemmy_websocket = { version = "=0.14.3", path = "../websocket" } lemmy_websocket = { version = "=0.14.4-rc.4", path = "../websocket" }
lemmy_db_views = { version = "=0.14.3", path = "../db_views" } lemmy_db_views = { version = "=0.14.4-rc.4", path = "../db_views" }
lemmy_db_views_actor = { version = "=0.14.3", path = "../db_views_actor" } lemmy_db_views_actor = { version = "=0.14.4-rc.4", path = "../db_views_actor" }
lemmy_db_schema = { version = "=0.14.3", path = "../db_schema" } lemmy_db_schema = { version = "=0.14.4-rc.4", path = "../db_schema" }
lemmy_api_common = { version = "=0.14.3", path = "../api_common" } lemmy_api_common = { version = "=0.14.4-rc.4", path = "../api_common" }
lemmy_apub = { version = "=0.14.3", path = "../apub" } lemmy_apub = { version = "=0.14.4-rc.4", path = "../apub" }
diesel = "1.4.8" diesel = "1.4.8"
actix = "0.12.0" actix = "0.12.0"
actix-web = { version = "4.0.0-beta.9", default-features = false, features = ["rustls"] } actix-web = { version = "4.0.0-beta.9", default-features = false, features = ["rustls"] }

View File

@ -1,4 +1,4 @@
use actix_web::{body::Body, error::ErrorBadRequest, *}; use actix_web::{body::AnyBody, error::ErrorBadRequest, *};
use anyhow::anyhow; use anyhow::anyhow;
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_db_views::site_view::SiteView; use lemmy_db_views::site_view::SiteView;
@ -15,7 +15,7 @@ pub fn config(cfg: &mut web::ServiceConfig) {
async fn node_info_well_known( async fn node_info_well_known(
context: web::Data<LemmyContext>, context: web::Data<LemmyContext>,
) -> Result<HttpResponse<Body>, LemmyError> { ) -> Result<HttpResponse<AnyBody>, LemmyError> {
let node_info = NodeInfoWellKnown { let node_info = NodeInfoWellKnown {
links: vec![NodeInfoWellKnownLinks { links: vec![NodeInfoWellKnownLinks {
rel: Url::parse("http://nodeinfo.diaspora.software/ns/schema/2.0")?, rel: Url::parse("http://nodeinfo.diaspora.software/ns/schema/2.0")?,

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_utils" name = "lemmy_utils"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"

View File

@ -58,7 +58,7 @@ pub struct SiteMetadata {
/// Fetches the post link html tags (like title, description, image, etc) /// Fetches the post link html tags (like title, description, image, etc)
pub async fn fetch_site_metadata(client: &Client, url: &Url) -> Result<SiteMetadata, LemmyError> { pub async fn fetch_site_metadata(client: &Client, url: &Url) -> Result<SiteMetadata, LemmyError> {
let response = retry(|| client.get(url.as_str()).send()).await?; let response = client.get(url.as_str()).send().await?;
let html = response let html = response
.text() .text()
@ -132,7 +132,7 @@ pub(crate) async fn fetch_pictrs(
utf8_percent_encode(image_url.as_str(), NON_ALPHANUMERIC) // TODO this might not be needed utf8_percent_encode(image_url.as_str(), NON_ALPHANUMERIC) // TODO this might not be needed
); );
let response = retry(|| client.get(&fetch_url).send()).await?; let response = client.get(&fetch_url).send().await?;
let response: PictrsResponse = response let response: PictrsResponse = response
.json() .json()
@ -201,8 +201,8 @@ pub async fn fetch_site_data(
} }
} }
async fn is_image_content_type(client: &Client, test: &Url) -> Result<(), LemmyError> { async fn is_image_content_type(client: &Client, url: &Url) -> Result<(), LemmyError> {
let response = retry(|| client.get(test.to_owned()).send()).await?; let response = client.get(url.as_str()).send().await?;
if response if response
.headers() .headers()
.get("Content-Type") .get("Content-Type")

View File

@ -46,6 +46,9 @@ pub struct Settings {
/// Maximum length of local community and user names /// Maximum length of local community and user names
#[default(20)] #[default(20)]
pub actor_name_max_length: usize, pub actor_name_max_length: usize,
/// Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object fetch through the search).
#[default(25)]
pub http_fetch_retry_limit: i32,
} }
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)] #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lemmy_websocket" name = "lemmy_websocket"
version = "0.14.3" version = "0.14.4-rc.4"
edition = "2018" edition = "2018"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"
@ -13,11 +13,11 @@ path = "src/lib.rs"
doctest = false doctest = false
[dependencies] [dependencies]
lemmy_utils = { version = "=0.14.3", path = "../utils" } lemmy_utils = { version = "=0.14.4-rc.4", path = "../utils" }
lemmy_api_common = { version = "=0.14.3", path = "../api_common" } lemmy_api_common = { version = "=0.14.4-rc.4", path = "../api_common" }
lemmy_db_schema = { version = "=0.14.3", path = "../db_schema" } lemmy_db_schema = { version = "=0.14.4-rc.4", path = "../db_schema" }
lemmy_db_views = { version = "=0.14.3", path = "../db_views" } lemmy_db_views = { version = "=0.14.4-rc.4", path = "../db_views" }
lemmy_db_views_actor = { version = "=0.14.3", path = "../db_views_actor" } lemmy_db_views_actor = { version = "=0.14.4-rc.4", path = "../db_views_actor" }
reqwest = { version = "0.11.4", features = ["json"] } reqwest = { version = "0.11.4", features = ["json"] }
tracing = "0.1.29" tracing = "0.1.29"
rand = "0.8.4" rand = "0.8.4"

View File

@ -491,7 +491,10 @@ impl ChatServer {
} else { } else {
let user_operation = UserOperation::from_str(op)?; let user_operation = UserOperation::from_str(op)?;
let fut = (message_handler)(context, msg.id, user_operation.clone(), data); let fut = (message_handler)(context, msg.id, user_operation.clone(), data);
rate_limiter.message().wrap(ip, fut).await match user_operation {
UserOperation::GetCaptcha => rate_limiter.post().wrap(ip, fut).await,
_ => rate_limiter.message().wrap(ip, fut).await,
}
} }
} }
} }

View File

@ -161,6 +161,12 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
.wrap(rate_limit.register()) .wrap(rate_limit.register())
.route(web::post().to(route_post_crud::<Register>)), .route(web::post().to(route_post_crud::<Register>)),
) )
.service(
// Handle captcha separately
web::resource("/user/get_captcha")
.wrap(rate_limit.post())
.route(web::get().to(route_get::<GetCaptcha>)),
)
// User actions // User actions
.service( .service(
web::scope("/user") web::scope("/user")
@ -178,7 +184,6 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
.route("/block", web::post().to(route_post::<BlockPerson>)) .route("/block", web::post().to(route_post::<BlockPerson>))
// Account actions. I don't like that they're in /user maybe /accounts // Account actions. I don't like that they're in /user maybe /accounts
.route("/login", web::post().to(route_post::<Login>)) .route("/login", web::post().to(route_post::<Login>))
.route("/get_captcha", web::get().to(route_get::<GetCaptcha>))
.route( .route(
"/delete_account", "/delete_account",
web::post().to(route_post_crud::<DeleteAccount>), web::post().to(route_post_crud::<DeleteAccount>),