Run Sieve scripts in async context

This commit is contained in:
mdecimus
2024-05-24 10:32:41 +02:00
parent ffdb7d766a
commit 4e7087d335
19 changed files with 363 additions and 458 deletions

View File

@@ -22,7 +22,6 @@ use smtp::{
scripts::ScriptResult,
};
use store::Stores;
use tokio::runtime::Handle;
use utils::config::Config;
use crate::smtp::{build_smtp, session::TestSession, TempDir};
@@ -419,15 +418,10 @@ async fn antispam() {
}
// Run script
let handle = Handle::current();
let span = span.clone();
let core_ = core.clone();
let script = script.clone();
match core
.spawn_worker(move || core_.run_script_blocking(script, params, handle, span))
.await
.unwrap()
{
match core_.run_script(script, params, span).await {
ScriptResult::Accept { modifications } => {
if modifications.len() != expected_headers.len() {
panic!(

View File

@@ -37,7 +37,6 @@ use smtp::{
scripts::ScriptResult,
};
use store::Stores;
use tokio::runtime::Handle;
use utils::config::Config;
const CONFIG: &str = r#"
@@ -182,14 +181,9 @@ async fn sieve_scripts() {
.set_variable("from", "john.doe@example.org")
.with_envelope(&core.core, &session)
.await;
let handle = Handle::current();
let span = span.clone();
let core_ = core.clone();
match core
.spawn_worker(move || core_.run_script_blocking(script, params, handle, span))
.await
.unwrap()
{
match core_.run_script(script, params, span).await {
ScriptResult::Accept { .. } => (),
ScriptResult::Reject(message) => panic!("{}", message),
err => {