Added thing
This commit is contained in:
parent
8cc8561e6a
commit
2a28b63c08
|
@ -8,6 +8,7 @@ pub(crate) struct Config {
|
|||
pub access_token: String,
|
||||
pub channel: String,
|
||||
pub homeserver: String,
|
||||
pub target: String,
|
||||
}
|
||||
|
||||
pub(crate) fn get_config(file: Option<&str>) -> Result<Config> {
|
||||
|
|
|
@ -48,13 +48,19 @@ extern "C" fn message_handler_wrapper(message: *const c_char) {
|
|||
}
|
||||
|
||||
async fn message_handler(message: String) -> Result<()> {
|
||||
let config = get_config();
|
||||
|
||||
let message = MessageParser::default().parse(&message).unwrap();
|
||||
|
||||
let message_body = message.body_text(0).unwrap();
|
||||
let message_sender = message.sender().unwrap().as_list().unwrap()[0]
|
||||
let message_sender = message.from().unwrap().as_list().unwrap()[0]
|
||||
.address()
|
||||
.unwrap();
|
||||
|
||||
if message.to().unwrap().first().unwrap().address().unwrap() != &config.target {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let message = format!("New mail from {message_sender}:\n{message_body}");
|
||||
|
||||
send_message(&message).await?;
|
||||
|
|
Loading…
Reference in a new issue