From 0f3c247069a3692e034563db55c9ab62c25dfafc Mon Sep 17 00:00:00 2001 From: silverpill Date: Sat, 25 Feb 2023 16:37:24 +0000 Subject: [PATCH] Put activities generated by CLI commands in a queue --- CHANGELOG.md | 4 ++++ mitra-cli/src/cli.rs | 4 ++-- src/activitypub/deliverer.rs | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc48a98..d3eea3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Added `federation` parameter group to configuration. - Add empty `spoiler_text` property to Mastodon API Status object. +### Changed + +- Put activities generated by CLI commands in a queue instead of immediately sending them. + ### Deprecated - Deprecated `proxy_url` configuration parameter (replaced by `federation.proxy_url`). diff --git a/mitra-cli/src/cli.rs b/mitra-cli/src/cli.rs index ffa95b1..b8f61ee 100644 --- a/mitra-cli/src/cli.rs +++ b/mitra-cli/src/cli.rs @@ -244,7 +244,7 @@ impl DeleteProfile { deletion_queue.process(config).await; // Send Delete(Person) activities if let Some(activity) = maybe_delete_person { - activity.deliver().await?; + activity.enqueue(db_client).await?; }; println!("profile deleted"); Ok(()) @@ -279,7 +279,7 @@ impl DeletePost { deletion_queue.process(config).await; // Send Delete(Note) activity if let Some(activity) = maybe_delete_note { - activity.deliver().await?; + activity.enqueue(db_client).await?; }; println!("post deleted"); Ok(()) diff --git a/src/activitypub/deliverer.rs b/src/activitypub/deliverer.rs index 4ac3a66..47554e0 100644 --- a/src/activitypub/deliverer.rs +++ b/src/activitypub/deliverer.rs @@ -252,7 +252,7 @@ impl OutgoingActivity { } } - pub async fn deliver( + pub(super) async fn deliver( self, ) -> Result<(), DelivererError> { deliver_activity_worker( @@ -264,7 +264,7 @@ impl OutgoingActivity { ).await } - pub fn spawn_deliver(self) -> () { + pub(super) fn spawn_deliver(self) -> () { tokio::spawn(async move { self.deliver().await.unwrap_or_else(|err| { log::error!("{}", err);