diff --git a/Cargo.lock b/Cargo.lock
index 733cfbf..5f78cdd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -196,6 +196,15 @@ dependencies = [
"powerfmt",
]
+[[package]]
+name = "encoding_rs"
+version = "0.8.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59"
+dependencies = [
+ "cfg-if",
+]
+
[[package]]
name = "equivalent"
version = "1.0.1"
@@ -595,6 +604,15 @@ version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
+[[package]]
+name = "mail-parser"
+version = "0.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed5a1335c3a964788c90cb42ae04a34b5f2628e89566949ce3bd4ada695c0bcd"
+dependencies = [
+ "encoding_rs",
+]
+
[[package]]
name = "mailing-list-matrix-bridge"
version = "0.1.0"
@@ -602,6 +620,7 @@ dependencies = [
"color-eyre",
"eyre",
"futures",
+ "mail-parser",
"mlpa",
"ruma-client",
"ruma-client-api",
diff --git a/Cargo.toml b/Cargo.toml
index 53b658d..713c739 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,6 +7,7 @@ edition = "2021"
color-eyre = "0.6.3"
eyre = "0.6.12"
futures = "0.3.30"
+mail-parser = "0.9.3"
mlpa = "0.4.0"
ruma-client = { version = "0.13.0", features = ["hyper-native-tls", "client-api"] }
ruma-client-api = "0.18.0"
diff --git a/src/lib.rs b/src/lib.rs
index e26bc48..a1f56f4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,6 +1,10 @@
use config::Config;
use eyre::Result;
-use std::{ffi::c_char, sync::Mutex};
+use mail_parser::MessageParser;
+use std::{
+ ffi::{c_char, CStr},
+ sync::Mutex,
+};
use mlpa::Plugin;
use ruma_client::{http_client::HyperNativeTls, Client};
@@ -14,8 +18,8 @@ mod config;
pub extern "C" fn get_plugin() -> Plugin {
use mlpa::Optional::*;
Plugin {
- on_start: Some(on_start),
- message_handler: Some(message_handler),
+ on_start: Some(on_start_wrapper),
+ message_handler: Some(message_handler_wrapper),
}
}
@@ -23,14 +27,39 @@ static CLIENT: Mutex