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

@ -95,6 +95,23 @@ steps:
ref:
- 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
- name: publish to crates.io
image: rustlang/rust:nightly
@ -207,6 +224,23 @@ steps:
ref:
- 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
# services:
# - name: database

28
Cargo.lock generated
View File

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

View File

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

View File

@ -115,4 +115,6 @@
slur_filter: "(\bThis\b)|(\bis\b)|(\bsample\b)"
# Maximum length of local community and user names
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]
name = "lemmy_api"
version = "0.14.3"
version = "0.14.4-rc.4"
edition = "2018"
description = "A link aggregator for the fediverse"
license = "AGPL-3.0"
@ -13,15 +13,15 @@ path = "src/lib.rs"
doctest = false
[dependencies]
lemmy_apub = { version = "=0.14.3", path = "../apub" }
lemmy_apub_lib = { version = "=0.14.3", path = "../apub_lib" }
lemmy_utils = { version = "=0.14.3", path = "../utils" }
lemmy_db_schema = { version = "=0.14.3", path = "../db_schema" }
lemmy_db_views = { version = "=0.14.3", path = "../db_views" }
lemmy_db_views_moderator = { version = "=0.14.3", path = "../db_views_moderator" }
lemmy_db_views_actor = { version = "=0.14.3", path = "../db_views_actor" }
lemmy_api_common = { version = "=0.14.3", path = "../api_common" }
lemmy_websocket = { version = "=0.14.3", path = "../websocket" }
lemmy_apub = { version = "=0.14.4-rc.4", path = "../apub" }
lemmy_apub_lib = { version = "=0.14.4-rc.4", path = "../apub_lib" }
lemmy_utils = { version = "=0.14.4-rc.4", path = "../utils" }
lemmy_db_schema = { version = "=0.14.4-rc.4", path = "../db_schema" }
lemmy_db_views = { version = "=0.14.4-rc.4", path = "../db_views" }
lemmy_db_views_moderator = { version = "=0.14.4-rc.4", path = "../db_views_moderator" }
lemmy_db_views_actor = { version = "=0.14.4-rc.4", path = "../db_views_actor" }
lemmy_api_common = { version = "=0.14.4-rc.4", path = "../api_common" }
lemmy_websocket = { version = "=0.14.4-rc.4", path = "../websocket" }
diesel = "1.4.8"
bcrypt = "0.10.1"
chrono = { version = "0.4.19", features = ["serde"] }

View File

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

View File

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

View File

@ -1,6 +1,6 @@
[package]
name = "lemmy_apub"
version = "0.14.3"
version = "0.14.4-rc.4"
edition = "2018"
description = "A link aggregator for the fediverse"
license = "AGPL-3.0"
@ -13,13 +13,13 @@ path = "src/lib.rs"
doctest = false
[dependencies]
lemmy_utils = { version = "=0.14.3", path = "../utils" }
lemmy_apub_lib = { version = "=0.14.3", path = "../apub_lib" }
lemmy_db_schema = { version = "=0.14.3", path = "../db_schema" }
lemmy_db_views = { version = "=0.14.3", path = "../db_views" }
lemmy_db_views_actor = { version = "=0.14.3", path = "../db_views_actor" }
lemmy_api_common = { version = "=0.14.3", path = "../api_common" }
lemmy_websocket = { version = "=0.14.3", path = "../websocket" }
lemmy_utils = { version = "=0.14.4-rc.4", path = "../utils" }
lemmy_apub_lib = { version = "=0.14.4-rc.4", path = "../apub_lib" }
lemmy_db_schema = { version = "=0.14.4-rc.4", path = "../db_schema" }
lemmy_db_views = { version = "=0.14.4-rc.4", path = "../db_views" }
lemmy_db_views_actor = { version = "=0.14.4-rc.4", path = "../db_views_actor" }
lemmy_api_common = { version = "=0.14.4-rc.4", path = "../api_common" }
lemmy_websocket = { version = "=0.14.4-rc.4", path = "../websocket" }
diesel = "1.4.8"
activitystreams-kinds = "0.1.2"
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,
) -> Result<(), LemmyError> {
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 {
CreateOrUpdateType::Create => UserOperationCrud::CreateComment,
CreateOrUpdateType::Update => UserOperationCrud::EditComment,

View File

@ -14,6 +14,7 @@ pub mod create_or_update;
async fn get_notif_recipients(
actor: &ObjectId<ApubPerson>,
comment: &Comment,
do_send_email: bool,
context: &LemmyContext,
request_counter: &mut i32,
) -> Result<Vec<LocalUserId>, LemmyError> {
@ -27,5 +28,5 @@ async fn get_notif_recipients(
// anyway.
// 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);
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)]
pub(crate) struct WithContext<T> {
#[serde(rename = "@context")]
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
context: Vec<serde_json::Value>,
#[serde(flatten)]
inner: T,

View File

@ -81,6 +81,11 @@ where
);
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 res: WebfingerResponse = response

View File

@ -3,6 +3,7 @@ use anyhow::{anyhow, Context};
use lemmy_api_common::blocking;
use lemmy_db_schema::{newtypes::DbUrl, source::activity::Activity, DbPool};
use lemmy_utils::{location_info, settings::structs::Settings, LemmyError};
use serde::{Deserialize, Deserializer};
use std::net::IpAddr;
use url::{ParseError, Url};
@ -85,6 +86,25 @@ pub(crate) fn check_is_apub_id_valid(
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 {
Community,
Person,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,8 +11,10 @@ use url::Url;
#[serde(rename_all = "camelCase")]
pub struct CreateOrUpdateComment {
pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>,
pub(crate) object: Note,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>,
#[serde(default)]
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/smithereen/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")]
pub struct CreateOrUpdatePost {
pub(crate) actor: ObjectId<ApubPerson>,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) to: Vec<Url>,
pub(crate) object: Page,
#[serde(deserialize_with = "crate::deserialize_one_or_many")]
pub(crate) cc: Vec<Url>,
#[serde(rename = "type")]
pub(crate) kind: CreateOrUpdateType,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,10 +18,6 @@ use std::{
use tracing::info;
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(|| {
Client::builder()
.user_agent(build_user_agent(&Settings::get()))
@ -119,8 +115,8 @@ where
info!("Fetching remote object {}", self.to_string());
*request_counter += 1;
if *request_counter > REQUEST_LIMIT {
return Err(LemmyError::from(anyhow!("Request limit reached")));
if *request_counter > Settings::get().http_fetch_retry_limit {
return Err(LemmyError::from(anyhow!("Request retry limit reached")));
}
let res = retry(|| {

View File

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

View File

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

View File

@ -1,6 +1,6 @@
[package]
name = "lemmy_db_views"
version = "0.14.3"
version = "0.14.4-rc.4"
edition = "2018"
description = "A link aggregator for the fediverse"
license = "AGPL-3.0"
@ -11,7 +11,7 @@ documentation = "https://join-lemmy.org/docs/en/index.html"
doctest = false
[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"] }
serde = { version = "1.0.130", features = ["derive"] }
tracing = "0.1.29"

View File

@ -1,6 +1,6 @@
[package]
name = "lemmy_db_views_actor"
version = "0.14.3"
version = "0.14.4-rc.4"
edition = "2018"
description = "A link aggregator for the fediverse"
license = "AGPL-3.0"
@ -11,6 +11,6 @@ documentation = "https://join-lemmy.org/docs/en/index.html"
doctest = false
[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"] }
serde = { version = "1.0.130", features = ["derive"] }

View File

@ -1,6 +1,6 @@
[package]
name = "lemmy_db_views_moderator"
version = "0.14.3"
version = "0.14.4-rc.4"
edition = "2018"
description = "A link aggregator for the fediverse"
license = "AGPL-3.0"
@ -11,6 +11,6 @@ documentation = "https://join-lemmy.org/docs/en/index.html"
doctest = false
[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"] }
serde = { version = "1.0.130", features = ["derive"] }

View File

@ -1,6 +1,6 @@
[package]
name = "lemmy_routes"
version = "0.14.3"
version = "0.14.4-rc.4"
edition = "2018"
description = "A link aggregator for the fediverse"
license = "AGPL-3.0"
@ -11,13 +11,13 @@ documentation = "https://join-lemmy.org/docs/en/index.html"
doctest = false
[dependencies]
lemmy_utils = { version = "=0.14.3", path = "../utils" }
lemmy_websocket = { version = "=0.14.3", path = "../websocket" }
lemmy_db_views = { version = "=0.14.3", path = "../db_views" }
lemmy_db_views_actor = { version = "=0.14.3", path = "../db_views_actor" }
lemmy_db_schema = { version = "=0.14.3", path = "../db_schema" }
lemmy_api_common = { version = "=0.14.3", path = "../api_common" }
lemmy_apub = { version = "=0.14.3", path = "../apub" }
lemmy_utils = { version = "=0.14.4-rc.4", path = "../utils" }
lemmy_websocket = { version = "=0.14.4-rc.4", path = "../websocket" }
lemmy_db_views = { version = "=0.14.4-rc.4", path = "../db_views" }
lemmy_db_views_actor = { version = "=0.14.4-rc.4", path = "../db_views_actor" }
lemmy_db_schema = { version = "=0.14.4-rc.4", path = "../db_schema" }
lemmy_api_common = { version = "=0.14.4-rc.4", path = "../api_common" }
lemmy_apub = { version = "=0.14.4-rc.4", path = "../apub" }
diesel = "1.4.8"
actix = "0.12.0"
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 lemmy_api_common::blocking;
use lemmy_db_views::site_view::SiteView;
@ -15,7 +15,7 @@ pub fn config(cfg: &mut web::ServiceConfig) {
async fn node_info_well_known(
context: web::Data<LemmyContext>,
) -> Result<HttpResponse<Body>, LemmyError> {
) -> Result<HttpResponse<AnyBody>, LemmyError> {
let node_info = NodeInfoWellKnown {
links: vec![NodeInfoWellKnownLinks {
rel: Url::parse("http://nodeinfo.diaspora.software/ns/schema/2.0")?,

View File

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

View File

@ -58,7 +58,7 @@ pub struct SiteMetadata {
/// Fetches the post link html tags (like title, description, image, etc)
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
.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
);
let response = retry(|| client.get(&fetch_url).send()).await?;
let response = client.get(&fetch_url).send().await?;
let response: PictrsResponse = response
.json()
@ -201,8 +201,8 @@ pub async fn fetch_site_data(
}
}
async fn is_image_content_type(client: &Client, test: &Url) -> Result<(), LemmyError> {
let response = retry(|| client.get(test.to_owned()).send()).await?;
async fn is_image_content_type(client: &Client, url: &Url) -> Result<(), LemmyError> {
let response = client.get(url.as_str()).send().await?;
if response
.headers()
.get("Content-Type")

View File

@ -46,6 +46,9 @@ pub struct Settings {
/// Maximum length of local community and user names
#[default(20)]
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)]

View File

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

View File

@ -491,7 +491,10 @@ impl ChatServer {
} else {
let user_operation = UserOperation::from_str(op)?;
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())
.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
.service(
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>))
// Account actions. I don't like that they're in /user maybe /accounts
.route("/login", web::post().to(route_post::<Login>))
.route("/get_captcha", web::get().to(route_get::<GetCaptcha>))
.route(
"/delete_account",
web::post().to(route_post_crud::<DeleteAccount>),