Skip to content

refactor(mimefactory): add Encryption enum - #8573

Open
link2xt wants to merge 2 commits into
mainfrom
link2xt/encryption-enum
Open

refactor(mimefactory): add Encryption enum#8573
link2xt wants to merge 2 commits into
mainfrom
link2xt/encryption-enum

Conversation

@link2xt

@link2xt link2xt commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

This replaces independent data structures
which allowed invalid state of having both the public keys and the shared secret, or having a shared secret
but not encrypting the message because encryption_pubkeys was None instead of Some(Vec::new()).

@link2xt
link2xt force-pushed the link2xt/encryption-enum branch 2 times, most recently from f0f1d06 to d0a6268 Compare August 12, 2026 19:51
@link2xt
link2xt marked this pull request as ready for review August 12, 2026 19:57

@hpk42 hpk42 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good refactoring although it's a bit hard to know if it fully preserves behaviour especially around symmetric encryption -- it seems that should_encrypt_with_broadcast_secret is not actually used anymore.

Comment thread src/mimefactory.rs Outdated
// created before we had symmetric encryption,
// we show an error message.
let text = BROADCAST_INCOMPATIBILITY_MSG;
chat::add_info_msg(context, chat.id, text).await?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this adds a message to the DB which is a bit unexpected for the from_msg loader function returning a MimeFactory.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the message can be removed completely, it was for the old broadcast lists. Users should have migrated to channels by now.

Comment thread src/mimefactory.rs Outdated
Comment on lines +1641 to +1664
is_encrypted: bool,
will_be_encrypted: bool,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this creates a lot of unrelated churn in the diff, and i am not sure it's an improvement.

Comment thread src/mimefactory.rs
Comment on lines +77 to +79
/// Vector of pairs of recipient
/// addresses and OpenPGP keys
/// to use for encryption.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this partially repeats the types and has too short lines.

Suggested change
/// Vector of pairs of recipient
/// addresses and OpenPGP keys
/// to use for encryption.
/// Addresses and OpenPGP keys to use for encryption.

@link2xt
link2xt force-pushed the link2xt/encryption-enum branch 2 times, most recently from e484810 to 01f3d9b Compare August 13, 2026 16:40
Creating QR code or sending a message will still fail
with a shorter error, but no info message will be created anymore.
Most users should have migrated the channels by recreating them by now.

This change is needed for moving loading of the shared secret
to earlier stages of message preparation,
otherwise mimefactory will have to create these info messages
when loading the message into memory.
This replaces independent data structures
which allowed invalid state of having both the public keys
and the shared secret, or having a shared secret
but not encrypting the message because encryption_pubkeys
was None instead of Some(Vec::new()).
@link2xt
link2xt force-pushed the link2xt/encryption-enum branch from 01f3d9b to 5799581 Compare August 13, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants