diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ec73de..3412cf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Don't ignore `Delete(Person)` verification errors if database error subtype is not `NotFound`. +- Don't stop activity processing on invalid local mentions. ## [1.9.0] - 2023-01-08 diff --git a/src/activitypub/fetcher/helpers.rs b/src/activitypub/fetcher/helpers.rs index a63088f..3c622d3 100644 --- a/src/activitypub/fetcher/helpers.rs +++ b/src/activitypub/fetcher/helpers.rs @@ -146,8 +146,10 @@ pub async fn get_or_import_profile_by_actor_address( &acct, ).await { Ok(profile) => profile, - Err(DatabaseError::NotFound(_)) => { - // TODO: don't fetch if address is local + Err(db_error @ DatabaseError::NotFound(_)) => { + if actor_address.hostname == instance.hostname() { + return Err(db_error.into()); + }; import_profile_by_actor_address( db_client, instance, diff --git a/src/activitypub/handlers/create.rs b/src/activitypub/handlers/create.rs index 376f130..8e6097a 100644 --- a/src/activitypub/handlers/create.rs +++ b/src/activitypub/handlers/create.rs @@ -20,6 +20,7 @@ use crate::activitypub::{ vocabulary::*, }; use crate::config::{Config, Instance}; +use crate::database::DatabaseError; use crate::errors::{ConversionError, ValidationError}; use crate::models::attachments::queries::create_attachment; use crate::models::posts::{ @@ -275,8 +276,12 @@ pub async fn handle_note( &actor_address, ).await { Ok(profile) => profile, - Err(HandlerError::FetchError(error)) => { + Err(error @ ( + HandlerError::FetchError(_) | + HandlerError::DatabaseError(DatabaseError::NotFound(_)) + )) => { // Ignore mention if fetcher fails + // Ignore mention if local address is not valid log::warn!( "failed to find mentioned profile {}: {}", actor_address,