fix(events): properly check encryption status

This commit is contained in:
Ryan 2025-03-09 03:40:22 -04:00
parent 884081d414
commit 1a2af8b7aa
Signed by: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3

View File

@ -33,8 +33,8 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
let mut is_encrypted = false; let mut is_encrypted = false;
if let Some(ref sender) = sender { if let Some(ref sender) = sender {
let ncr_options = globals.get::<Table>("NcrOptions").ok(); let mut ncr_options = None;
if let Some(ref options) = ncr_options if let Ok(options) = globals.get::<Table>("NcrOptions")
&& let Ok(decrypt) = globals.get::<Function>("ncr_decrypt") && let Ok(decrypt) = globals.get::<Function>("ncr_decrypt")
&& let Some(plaintext) = decrypt && let Some(plaintext) = decrypt
.call::<String>((options.clone(), content.clone())) .call::<String>((options.clone(), content.clone()))
@ -43,6 +43,7 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
.and_then(|s| trim_header(s).ok()) .and_then(|s| trim_header(s).ok())
{ {
is_encrypted = true; is_encrypted = true;
ncr_options = Some(options);
plaintext.clone_into(&mut content); plaintext.clone_into(&mut content);
info!("decrypted message from {sender}: {content}"); info!("decrypted message from {sender}: {content}");
} }