diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index 50bdac751..01b5472b1 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -877,7 +877,7 @@ diesel::table! { send_community_followers_of -> Nullable, send_all_instances -> Bool, actor_type -> ActorTypeEnum, - actor_apub_id -> Nullable, + actor_apub_id -> Text, } } diff --git a/crates/db_schema/src/source/activity.rs b/crates/db_schema/src/source/activity.rs index 6eb17f606..5ce6466f1 100644 --- a/crates/db_schema/src/source/activity.rs +++ b/crates/db_schema/src/source/activity.rs @@ -65,7 +65,7 @@ pub struct SentActivity { pub send_community_followers_of: Option, pub send_all_instances: bool, pub actor_type: ActorType, - pub actor_apub_id: Option, + pub actor_apub_id: DbUrl, } #[cfg_attr(feature = "full", derive(Insertable))] diff --git a/crates/federate/src/worker.rs b/crates/federate/src/worker.rs index 64a5f3a7e..6385e0fbb 100644 --- a/crates/federate/src/worker.rs +++ b/crates/federate/src/worker.rs @@ -188,13 +188,13 @@ impl InstanceWorker { self.state.last_successful_published_time = Some(activity.published); return Ok(()); } - // TODO: make db column not null - let Some(actor_apub_id) = &activity.actor_apub_id else { - return Ok(()); // activity was inserted before persistent queue was activated - }; - let actor = get_actor_cached(&mut self.context.pool(), activity.actor_type, actor_apub_id) - .await - .context("failed getting actor instance (was it marked deleted / removed?)")?; + let actor = get_actor_cached( + &mut self.context.pool(), + activity.actor_type, + &activity.actor_apub_id, + ) + .await + .context("failed getting actor instance (was it marked deleted / removed?)")?; let object = WithContext::new(object.clone(), FEDERATION_CONTEXT.deref().clone()); let inbox_urls = inbox_urls.into_iter().collect(); diff --git a/migrations/2024-05-30-085949_activity_actor_not_null/down.sql b/migrations/2024-05-30-085949_activity_actor_not_null/down.sql new file mode 100644 index 000000000..ddf10e978 --- /dev/null +++ b/migrations/2024-05-30-085949_activity_actor_not_null/down.sql @@ -0,0 +1 @@ +ALTER TABLE sent_activity ALTER COLUMN actor_apub_id DROP NOT NULL; \ No newline at end of file diff --git a/migrations/2024-05-30-085949_activity_actor_not_null/up.sql b/migrations/2024-05-30-085949_activity_actor_not_null/up.sql new file mode 100644 index 000000000..bf5c8bac5 --- /dev/null +++ b/migrations/2024-05-30-085949_activity_actor_not_null/up.sql @@ -0,0 +1 @@ +ALTER TABLE sent_activity ALTER COLUMN actor_apub_id SET NOT NULL; \ No newline at end of file