Skip to content

Commit

Permalink
Merge branch 'main' into post_remove_delete_federation_fix0
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketDerp committed Jul 14, 2023
2 parents 22caa88 + e9e7654 commit 620f036
Show file tree
Hide file tree
Showing 41 changed files with 421 additions and 309 deletions.
8 changes: 4 additions & 4 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tab_spaces = 2
edition="2021"
imports_layout="HorizontalVertical"
imports_granularity="Crate"
group_imports="One"
edition = "2021"
imports_layout = "HorizontalVertical"
imports_granularity = "Crate"
group_imports = "One"
12 changes: 12 additions & 0 deletions .woodpecker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ pipeline:
commands:
- prettier -c . '!**/volumes' '!**/dist' '!target' '!**/translations'

taplo_check:
image: tamasfe/taplo:0.8.1
commands:
- taplo format --check

# use minimum supported rust version for most steps
cargo_fmt:
image: *muslrust_image
Expand Down Expand Up @@ -87,6 +92,13 @@ pipeline:
- "! cargo tree -p lemmy_api_common --no-default-features -i diesel"
# when:
# platform: linux/amd64
lemmy_api_common_works_with_wasm:
image: *muslrust_image
environment:
CARGO_HOME: .cargo
commands:
- "rustup target add wasm32-unknown-unknown"
- "cargo check --target wasm32-unknown-unknown -p lemmy_api_common"

check_defaults_hjson_updated:
image: *muslrust_image
Expand Down
36 changes: 10 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 32 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,29 @@ debug = 0

[features]
embed-pictrs = ["pict-rs"]
console = ["console-subscriber", "opentelemetry", "opentelemetry-otlp", "tracing-opentelemetry", "reqwest-tracing/opentelemetry_0_16"]
console = [
"console-subscriber",
"opentelemetry",
"opentelemetry-otlp",
"tracing-opentelemetry",
"reqwest-tracing/opentelemetry_0_16",
]
json-log = ["tracing-subscriber/json"]
prometheus-metrics = ["prometheus", "actix-web-prom"]
default = []

[workspace]
members = [
"crates/api",
"crates/api_crud",
"crates/api_common",
"crates/apub",
"crates/utils",
"crates/db_schema",
"crates/db_views",
"crates/db_views_actor",
"crates/db_views_actor",
"crates/routes"
"crates/api",
"crates/api_crud",
"crates/api_common",
"crates/apub",
"crates/utils",
"crates/db_schema",
"crates/db_views",
"crates/db_views_actor",
"crates/db_views_actor",
"crates/routes",
]

[workspace.dependencies]
Expand All @@ -61,13 +67,21 @@ lemmy_routes = { version = "=0.18.1", path = "./crates/routes" }
lemmy_db_views = { version = "=0.18.1", path = "./crates/db_views" }
lemmy_db_views_actor = { version = "=0.18.1", path = "./crates/db_views_actor" }
lemmy_db_views_moderator = { version = "=0.18.1", path = "./crates/db_views_moderator" }
activitypub_federation = { version = "0.4.5", default-features = false, features = ["actix-web"] }
activitypub_federation = { version = "0.4.5", default-features = false, features = [
"actix-web",
] }
diesel = "2.1.0"
diesel_migrations = "2.1.0"
diesel-async = "0.3.1"
serde = { version = "1.0.167", features = ["derive"] }
serde_with = "3.0.0"
actix-web = { version = "4.3.1", default-features = false, features = ["macros", "rustls", "compress-brotli", "compress-gzip", "compress-zstd"] }
actix-web = { version = "4.3.1", default-features = false, features = [
"macros",
"rustls",
"compress-brotli",
"compress-gzip",
"compress-zstd",
] }
tracing = "0.1.37"
tracing-actix-web = { version = "0.7.5", default-features = false }
tracing-error = "0.2.0"
Expand All @@ -87,7 +101,9 @@ base64 = "0.21.2"
uuid = { version = "1.4.0", features = ["serde", "v4"] }
async-trait = "0.1.71"
captcha = "0.0.9"
anyhow = { version = "1.0.71", features = ["backtrace"] } # backtrace is on by default on nightly, but not stable rust
anyhow = { version = "1.0.71", features = [
"backtrace",
] } # backtrace is on by default on nightly, but not stable rust
diesel_ltree = "0.3.0"
typed-builder = "0.15.0"
serial_test = "2.0.0"
Expand All @@ -96,7 +112,7 @@ sha2 = "0.10.7"
regex = "1.9.0"
once_cell = "1.18.0"
diesel-derive-newtype = "2.1.0"
diesel-derive-enum = {version = "2.1.0", features = ["postgres"] }
diesel-derive-enum = { version = "2.1.0", features = ["postgres"] }
strum = "0.25.0"
strum_macros = "0.25.1"
itertools = "0.11.0"
Expand All @@ -108,7 +124,7 @@ rand = "0.8.5"
opentelemetry = { version = "0.19.0", features = ["rt-tokio"] }
tracing-opentelemetry = { version = "0.19.0" }
ts-rs = { version = "6.2", features = ["serde-compat", "chrono-impl"] }
rustls = { version ="0.21.3", features = ["dangerous_configuration"]}
rustls = { version = "0.21.3", features = ["dangerous_configuration"] }
futures-util = "0.3.28"
tokio-postgres = "0.7.8"
tokio-postgres-rustls = "0.10.0"
Expand Down
37 changes: 28 additions & 9 deletions crates/api_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,25 @@ path = "src/lib.rs"
doctest = false

[features]
full = ["tracing", "rosetta-i18n", "chrono", "lemmy_utils",
"lemmy_db_views/full", "lemmy_db_views_actor/full", "lemmy_db_views_moderator/full",
"percent-encoding", "encoding", "reqwest-middleware", "webpage", "ts-rs"]
full = [
"tracing",
"rosetta-i18n",
"chrono",
"lemmy_utils",
"lemmy_db_views/full",
"lemmy_db_views_actor/full",
"lemmy_db_views_moderator/full",
"percent-encoding",
"encoding",
"reqwest-middleware",
"webpage",
"ts-rs",
"tokio",
"uuid",
"reqwest",
"actix-web",
"futures",
]

[dependencies]
lemmy_db_views = { workspace = true }
Expand All @@ -33,12 +49,15 @@ reqwest-middleware = { workspace = true, optional = true }
regex = { workspace = true }
rosetta-i18n = { workspace = true, optional = true }
percent-encoding = { workspace = true, optional = true }
webpage = { version = "1.6", default-features = false, features = ["serde"], optional = true }
webpage = { version = "1.6", default-features = false, features = [
"serde",
], optional = true }
encoding = { version = "0.2.33", optional = true }
anyhow = { workspace = true }
futures = { workspace = true }
uuid = { workspace = true }
tokio = { workspace = true }
reqwest = { workspace = true }
futures = { workspace = true, optional = true }
uuid = { workspace = true, optional = true }
tokio = { workspace = true, optional = true }
reqwest = { workspace = true, optional = true }
ts-rs = { workspace = true, optional = true }
actix-web = { workspace = true }
actix-web = { workspace = true, optional = true }
getrandom = { version = "0.2.10", features = ["js"] }
2 changes: 1 addition & 1 deletion crates/api_crud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ url = { workspace = true }
async-trait = { workspace = true }
webmention = "0.4.0"
chrono = { workspace = true }
uuid = { workspace = true }
uuid = { workspace = true }
2 changes: 1 addition & 1 deletion crates/apub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ chrono = { workspace = true }
serde_json = { workspace = true }
serde = { workspace = true }
actix-web = { workspace = true }
tokio = {workspace = true}
tokio = { workspace = true }
tracing = { workspace = true }
strum_macros = { workspace = true }
url = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/apub/src/activities/block/block_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
verify_person_in_community,
},
activity_lists::AnnouncableActivities,
insert_activity,
insert_received_activity,
objects::{instance::remote_instance_inboxes, person::ApubPerson},
protocol::activities::block::block_user::BlockUser,
};
Expand Down Expand Up @@ -124,6 +124,7 @@ impl ActivityHandler for BlockUser {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_is_public(&self.to, &self.cc)?;
match self.target.dereference(context).await? {
SiteOrCommunity::Site(site) => {
Expand All @@ -147,7 +148,6 @@ impl ActivityHandler for BlockUser {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_activity(&self.id, &self, false, false, context).await?;
let expires = self.expires.map(|u| u.naive_local());
let mod_person = self.actor.dereference(context).await?;
let blocked_person = self.object.dereference(context).await?;
Expand Down
4 changes: 2 additions & 2 deletions crates/apub/src/activities/block/undo_block_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
verify_is_public,
},
activity_lists::AnnouncableActivities,
insert_activity,
insert_received_activity,
objects::{instance::remote_instance_inboxes, person::ApubPerson},
protocol::activities::block::{block_user::BlockUser, undo_block_user::UndoBlockUser},
};
Expand Down Expand Up @@ -88,6 +88,7 @@ impl ActivityHandler for UndoBlockUser {

#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_is_public(&self.to, &self.cc)?;
verify_domains_match(self.actor.inner(), self.object.actor.inner())?;
self.object.verify(context).await?;
Expand All @@ -96,7 +97,6 @@ impl ActivityHandler for UndoBlockUser {

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
insert_activity(&self.id, &self, false, false, context).await?;
let expires = self.object.expires.map(|u| u.naive_local());
let mod_person = self.actor.dereference(context).await?;
let blocked_person = self.object.object.dereference(context).await?;
Expand Down
6 changes: 3 additions & 3 deletions crates/apub/src/activities/community/announce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
verify_person_in_community,
},
activity_lists::AnnouncableActivities,
insert_activity,
insert_received_activity,
objects::community::ApubCommunity,
protocol::{
activities::community::announce::{AnnounceActivity, RawAnnouncableActivities},
Expand Down Expand Up @@ -133,14 +133,14 @@ impl ActivityHandler for AnnounceActivity {
}

#[tracing::instrument(skip_all)]
async fn verify(&self, _context: &Data<Self::DataType>) -> Result<(), LemmyError> {
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_received_activity(&self.id, context).await?;
verify_is_public(&self.to, &self.cc)?;
Ok(())
}

#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_activity(&self.id, &self, false, false, context).await?;
let object: AnnouncableActivities = self.object.object(context).await?.try_into()?;
// This is only for sending, not receiving so we reject it.
if let AnnouncableActivities::Page(_) = object {
Expand Down

0 comments on commit 620f036

Please sign in to comment.