- LEMMY_RATE_LIMIT__POST=99999
- LEMMY_RATE_LIMIT__REGISTER=99999
- LEMMY_CAPTCHA__ENABLED=false
+ - LEMMY_TEST_SEND_SYNC=1
- RUST_BACKTRACE=1
- RUST_LOG=debug
depends_on:
- LEMMY_RATE_LIMIT__POST=99999
- LEMMY_RATE_LIMIT__REGISTER=99999
- LEMMY_CAPTCHA__ENABLED=false
+ - LEMMY_TEST_SEND_SYNC=1
- RUST_BACKTRACE=1
- RUST_LOG=debug
depends_on:
- LEMMY_RATE_LIMIT__POST=99999
- LEMMY_RATE_LIMIT__REGISTER=99999
- LEMMY_CAPTCHA__ENABLED=false
+ - LEMMY_TEST_SEND_SYNC=1
- RUST_BACKTRACE=1
- RUST_LOG=debug
depends_on:
- LEMMY_RATE_LIMIT__POST=99999
- LEMMY_RATE_LIMIT__REGISTER=99999
- LEMMY_CAPTCHA__ENABLED=false
+ - LEMMY_TEST_SEND_SYNC=1
- RUST_BACKTRACE=1
- RUST_LOG=debug
depends_on:
- LEMMY_RATE_LIMIT__POST=99999
- LEMMY_RATE_LIMIT__REGISTER=99999
- LEMMY_CAPTCHA__ENABLED=false
+ - LEMMY_TEST_SEND_SYNC=1
- RUST_BACKTRACE=1
- RUST_LOG=debug
depends_on:
use log::{debug, warn};
use reqwest::Client;
use serde::{export::fmt::Debug, Deserialize, Serialize};
-use std::{collections::BTreeMap, future::Future, pin::Pin};
+use std::{collections::BTreeMap, future::Future, pin::Pin, env};
use url::Url;
/// Sends a local activity to a single, remote actor.
actor_id: actor.actor_id()?,
private_key: actor.private_key().context(location_info!())?,
};
- activity_sender.queue::<SendActivityTask>(message)?;
+ if env::var("LEMMY_TEST_SEND_SYNC").is_ok() {
+ do_send(message, &Client::default()).await?;
+ } else {
+ activity_sender.queue::<SendActivityTask>(message)?;
+ }
}
Ok(())
fn run(self, state: Self::State) -> Self::Future {
Box::pin(async move {
- let mut headers = BTreeMap::<String, String>::new();
- headers.insert("Content-Type".into(), "application/json".into());
- let result = sign_and_send(
- &state.client,
- headers,
- &self.inbox,
- self.activity.clone(),
- &self.actor_id,
- self.private_key.to_owned(),
- )
- .await;
+ do_send(self, &state.client).await
+ })
+ }
+}
- if let Err(e) = result {
- warn!("{}", e);
- return Err(anyhow!(
+async fn do_send(task: SendActivityTask, client: &Client) -> Result<(), Error>{
+ let mut headers = BTreeMap::<String, String>::new();
+ headers.insert("Content-Type".into(), "application/json".into());
+ let result = sign_and_send(
+ client,
+ headers,
+ &task.inbox,
+ task.activity.clone(),
+ &task.actor_id,
+ task.private_key.to_owned(),
+ )
+ .await;
+
+ if let Err(e) = result {
+ warn!("{}", e);
+ return Err(anyhow!(
"Failed to send activity {} to {}",
- &self.activity,
- self.inbox
+ &task.activity,
+ task.inbox
));
- }
- Ok(())
- })
}
+ Ok(())
}
pub fn create_activity_queue() -> QueueHandle {