[[package]]
name = "activitypub_federation"
-version = "0.2.2"
+version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "690ed975ab70b883b4f0776f60fd7f23a7484a49f4257e7672e64d0990e95771"
+checksum = "dd9ae511df7135c271dca3ef3751f5528891c965e47d8d7a70fed9d2f1e5b6b1"
dependencies = [
"activitypub_federation_derive",
"actix-web",
"base64",
"chrono",
"derive_builder 0.11.2",
+ "dyn-clone",
"http",
"http-signature-normalization-actix",
"http-signature-normalization-reqwest",
"syn 1.0.100",
]
+[[package]]
+name = "dyn-clone"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2"
+
[[package]]
name = "either"
version = "1.8.0"
lemmy_api_common = { version = "=0.16.5", path = "crates/api_common" }
lemmy_websocket = { version = "=0.16.5", path = "./crates/websocket" }
lemmy_routes = { version = "=0.16.5", path = "./crates/routes" }
-activitypub_federation = "0.2.0"
+activitypub_federation = "0.2.3"
diesel = "2.0.0"
diesel_migrations = "2.0.0"
serde = { version = "1.0.145", features = ["derive"] }
lemmy_db_views_actor = { version = "=0.16.5", path = "../db_views_actor", features = ["full"] }
lemmy_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] }
lemmy_websocket = { version = "=0.16.5", path = "../websocket" }
-activitypub_federation = { version = "0.2.2" }
+activitypub_federation = "0.2.3"
diesel = "2.0.0"
bcrypt = "0.13.0"
chrono = { version = "0.4.22", features = ["serde"], default-features = false }
lemmy_db_views_actor = { version = "=0.16.5", path = "../db_views_actor", features = ["full"] }
lemmy_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] }
lemmy_websocket = { version = "=0.16.5", path = "../websocket" }
-activitypub_federation = { version = "0.2.2" }
+activitypub_federation = "0.2.3"
bcrypt = "0.13.0"
serde_json = { version = "1.0.85", features = ["preserve_order"] }
serde = { version = "1.0.145", features = ["derive"] }
lemmy_db_views_actor = { version = "=0.16.5", path = "../db_views_actor", features = ["full"] }
lemmy_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] }
lemmy_websocket = { version = "=0.16.5", path = "../websocket" }
-activitypub_federation = { version = "0.2.2" }
+activitypub_federation = "0.2.3"
diesel = "2.0.0"
activitystreams-kinds = "0.2.1"
chrono = { version = "0.4.22", features = ["serde"], default-features = false }
verify_person_in_community,
},
activity_lists::AnnouncableActivities,
- check_apub_id_valid,
- fetch_local_site_data,
local_instance,
objects::{community::ApubCommunity, instance::remote_instance_inboxes, person::ApubPerson},
protocol::activities::block::block_user::BlockUser,
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
-
verify_is_public(&self.to, &self.cc)?;
match self
.target
-use crate::{
- activities::{
- block::{generate_cc, SiteOrCommunity},
- community::{announce::GetCommunity, send_activity_in_community},
- generate_activity_id,
- send_lemmy_activity,
- verify_is_public,
- },
- activity_lists::AnnouncableActivities,
- check_apub_id_valid,
- fetch_local_site_data,
- local_instance,
- objects::{community::ApubCommunity, instance::remote_instance_inboxes, person::ApubPerson},
- protocol::activities::block::{block_user::BlockUser, undo_block_user::UndoBlockUser},
- ActorType,
-};
use activitypub_federation::{
core::object_id::ObjectId,
data::Data,
use lemmy_websocket::LemmyContext;
use url::Url;
+use crate::{
+ activities::{
+ block::{generate_cc, SiteOrCommunity},
+ community::{announce::GetCommunity, send_activity_in_community},
+ generate_activity_id,
+ send_lemmy_activity,
+ verify_is_public,
+ },
+ activity_lists::AnnouncableActivities,
+ local_instance,
+ objects::{community::ApubCommunity, instance::remote_instance_inboxes, person::ApubPerson},
+ protocol::activities::block::{block_user::BlockUser, undo_block_user::UndoBlockUser},
+ ActorType,
+};
+
impl UndoBlockUser {
#[tracing::instrument(skip_all)]
pub async fn send(
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
-
verify_is_public(&self.to, &self.cc)?;
verify_domains_match(self.actor.inner(), self.object.actor.inner())?;
self.object.verify(context, request_counter).await?;
verify_person_in_community,
},
activity_lists::AnnouncableActivities,
- check_apub_id_valid,
- fetch_local_site_data,
generate_moderators_url,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson},
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
-
verify_is_public(&self.to, &self.cc)?;
let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
use crate::{
activities::{generate_activity_id, send_lemmy_activity, verify_is_public},
activity_lists::AnnouncableActivities,
- check_apub_id_valid,
- fetch_local_site_data,
insert_activity,
objects::community::ApubCommunity,
protocol::{
};
use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler};
use activitystreams_kinds::{activity::AnnounceType, public};
-use lemmy_api_common::utils::blocking;
use lemmy_utils::error::LemmyError;
use lemmy_websocket::LemmyContext;
use tracing::debug;
#[tracing::instrument(skip_all)]
async fn verify(
&self,
- context: &Data<LemmyContext>,
+ _context: &Data<LemmyContext>,
_request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
-
verify_is_public(&self.to, &self.cc)?;
Ok(())
}
verify_person_in_community,
},
activity_lists::AnnouncableActivities,
- check_apub_id_valid,
- fetch_local_site_data,
generate_moderators_url,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson},
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
-
verify_is_public(&self.to, &self.cc)?;
let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
use crate::{
activities::{generate_activity_id, send_lemmy_activity, verify_person_in_community},
- check_apub_id_valid,
- fetch_local_site_data,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::community::report::Report,
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
-
let community = self.to[0]
.dereference(context, local_instance(context), request_counter)
.await?;
verify_person_in_community,
},
activity_lists::AnnouncableActivities,
- check_apub_id_valid,
- fetch_local_site_data,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::community::update::UpdateCommunity,
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
verify_is_public(&self.to, &self.cc)?;
let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
verify_person_in_community,
},
activity_lists::AnnouncableActivities,
- check_apub_id_valid,
- fetch_local_site_data,
local_instance,
mentions::MentionOrValue,
objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson},
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
-
verify_is_public(&self.to, &self.cc)?;
let post = self.object.get_parents(context, request_counter).await?.0;
let community = self.get_community(context, request_counter).await?;
verify_person_in_community,
},
activity_lists::AnnouncableActivities,
- check_apub_id_valid,
- fetch_local_site_data,
objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost},
protocol::activities::{create_or_update::post::CreateOrUpdatePost, CreateOrUpdateType},
ActorType,
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
verify_is_public(&self.to, &self.cc)?;
let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
use crate::{
activities::{generate_activity_id, send_lemmy_activity, verify_person},
- check_apub_id_valid,
- fetch_local_site_data,
objects::{person::ApubPerson, private_message::ApubPrivateMessage},
protocol::activities::{
create_or_update::private_message::CreateOrUpdatePrivateMessage,
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
-
verify_person(&self.actor, context, request_counter).await?;
verify_domains_match(self.actor.inner(), self.object.id.inner())?;
verify_domains_match(self.to[0].inner(), self.object.to[0].inner())?;
deletion::{receive_delete_action, verify_delete_activity, DeletableObjects},
generate_activity_id,
},
- check_apub_id_valid,
- fetch_local_site_data,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::{activities::deletion::delete::Delete, IdOrNestedObject},
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
verify_delete_activity(self, self.summary.is_some(), context, request_counter).await?;
Ok(())
}
use crate::{
activities::{generate_activity_id, send_lemmy_activity, verify_is_public, verify_person},
- check_apub_id_valid,
- fetch_local_site_data,
local_instance,
objects::{instance::remote_instance_inboxes, person::ApubPerson},
protocol::activities::deletion::delete_user::DeleteUser,
utils::verify_urls_match,
};
use activitystreams_kinds::{activity::DeleteType, public};
-use lemmy_api_common::utils::{blocking, delete_user_account};
+use lemmy_api_common::utils::delete_user_account;
use lemmy_utils::error::LemmyError;
use lemmy_websocket::LemmyContext;
use url::Url;
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
verify_is_public(&self.to, &[])?;
verify_person(&self.actor, context, request_counter).await?;
verify_urls_match(self.actor.inner(), self.object.inner())?;
deletion::{receive_delete_action, verify_delete_activity, DeletableObjects},
generate_activity_id,
},
- check_apub_id_valid,
- fetch_local_site_data,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::deletion::{delete::Delete, undo_delete::UndoDelete},
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
self.object.verify(context, request_counter).await?;
verify_delete_activity(
&self.object,
use crate::{
activities::{generate_activity_id, send_lemmy_activity},
- check_apub_id_valid,
- fetch_local_site_data,
local_instance,
protocol::activities::following::{accept::AcceptFollowCommunity, follow::FollowCommunity},
ActorType,
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
-
verify_urls_match(self.actor.inner(), self.object.object.inner())?;
self.object.verify(context, request_counter).await?;
Ok(())
verify_person,
verify_person_in_community,
},
- check_apub_id_valid,
- fetch_local_site_data,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::following::{accept::AcceptFollowCommunity, follow::FollowCommunity},
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
verify_person(&self.actor, context, request_counter).await?;
let community = self
.object
use crate::{
activities::{generate_activity_id, send_lemmy_activity, verify_person},
- check_apub_id_valid,
- fetch_local_site_data,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::following::{follow::FollowCommunity, undo_follow::UndoFollowCommunity},
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
verify_urls_match(self.actor.inner(), self.object.actor.inner())?;
verify_person(&self.actor, context, request_counter).await?;
self.object.verify(context, request_counter).await?;
voting::{undo_vote_comment, undo_vote_post},
},
activity_lists::AnnouncableActivities,
- check_apub_id_valid,
- fetch_local_site_data,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::voting::{
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
verify_urls_match(self.actor.inner(), self.object.actor.inner())?;
voting::{vote_comment, vote_post},
},
activity_lists::AnnouncableActivities,
- check_apub_id_valid,
- fetch_local_site_data,
local_instance,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::voting::vote::{Vote, VoteType},
context: &Data<LemmyContext>,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let local_site_data = blocking(context.pool(), fetch_local_site_data).await??;
- check_apub_id_valid(self.id(), &local_site_data, context.settings())
- .map_err(LemmyError::from_message)?;
let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
let enable_downvotes = blocking(context.pool(), LocalSite::read)
traits::{Actor, ApubObject},
InstanceSettings,
LocalInstance,
+ UrlVerifier,
};
use anyhow::Context;
+use async_trait::async_trait;
use diesel::PgConnection;
use lemmy_api_common::utils::blocking;
use lemmy_db_schema::{
.http_fetch_retry_limit(http_fetch_retry_limit)
.worker_count(worker_count)
.debug(federation_debug)
- // TODO No idea why, but you can't pass context.settings() to the verify_url_function closure
- // without the value getting captured.
.http_signature_compat(true)
+ .url_verifier(Box::new(VerifyUrlData(context.clone())))
.build()
.expect("configure federation");
LocalInstance::new(
})
}
+#[derive(Clone)]
+struct VerifyUrlData(LemmyContext);
+
+#[async_trait]
+impl UrlVerifier for VerifyUrlData {
+ async fn verify(&self, url: &Url) -> Result<(), &'static str> {
+ let local_site_data = blocking(self.0.pool(), fetch_local_site_data)
+ .await
+ .expect("read local site data")
+ .expect("read local site data");
+ check_apub_id_valid(url, &local_site_data, self.0.settings())
+ }
+}
+
/// Checks if the ID is allowed for sending or receiving.
///
/// In particular, it checks for:
/// `use_strict_allowlist` should be true only when parsing a remote community, or when parsing a
/// post/comment in a local community.
#[tracing::instrument(skip(settings, local_site_data))]
-// TODO This function needs to be called by incoming activities
fn check_apub_id_valid(
apub_id: &Url,
local_site_data: &LocalSiteData,
strum = "0.24.1"
strum_macros = "0.24.3"
serde_json = { version = "1.0.85", features = ["preserve_order"], optional = true }
-activitypub_federation = { version = "0.2.2", optional = true }
+activitypub_federation = { version = "0.2.3", optional = true }
lemmy_utils = { version = "=0.16.5", path = "../utils", optional = true }
bcrypt = { version = "0.13.0", optional = true }
diesel = { version = "2.0.0", features = ["postgres","chrono","r2d2","serde_json"], optional = true }
-Subproject commit 454debaede4cc932ac15fea9bf620cf1daf1ae4c
+Subproject commit f5d6f0eabafd559417bf8f203fd655f7858bffcf