fix: Don't remember old channel members in the database#7716
Merged
Conversation
Hocuri
commented
Jan 14, 2026
Comment on lines
+250
to
+274
| } else if let Some(fp) = must_have_only_one_recipient(&msg, &chat) { | ||
| // In a broadcast channel, only send member-added/removed messages | ||
| // to the affected member | ||
| let (authname, addr, public_key_bytes) = context | ||
| .sql | ||
| .query_row( | ||
| "SELECT c.authname, c.addr, k.public_key | ||
| FROM contacts c, public_keys k | ||
| WHERE c.fingerprint=?1 AND k.fingerprint=?1", | ||
| (fp?,), | ||
| |row| { | ||
| let authname: String = row.get(0)?; | ||
| let addr: String = row.get(1)?; | ||
| let public_key_bytes: Vec<u8> = row.get(2)?; | ||
|
|
||
| Ok((authname, addr, public_key_bytes)) | ||
| }, | ||
| ) | ||
| .await?; | ||
|
|
||
| recipients.push(addr.clone()); | ||
| to.push((authname, addr.clone())); | ||
|
|
||
| let public_key = SignedPublicKey::from_slice(&public_key_bytes)?; | ||
| encryption_pubkeys = Some(vec![(addr, public_key)]); |
Collaborator
Author
There was a problem hiding this comment.
This change is necessary because previously, the removed contact was loaded from the past_members table.
link2xt
reviewed
Jan 16, 2026
src/mimefactory.rs
Outdated
| let (authname, addr, public_key_bytes) = context | ||
| .sql | ||
| .query_row( | ||
| "SELECT c.authname, c.addr, k.public_key |
Collaborator
There was a problem hiding this comment.
Selecting from a cross-product looks inefficent, not sure if SQLite can optimize it.
I'd rewrite this with JOIN or even use a transaction and just do two separate SELECT queries:
SELECT c.authname, c.addr, k.public_key
FROM contacts c
JOIN public_keys k ON c.fingerprint = k.fingerprint
WHERE c.fingerprint = ?
link2xt
approved these changes
Jan 16, 2026
iequidoo
approved these changes
Jan 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a bug that old channel members were remembered in the database even after they left the channel. Concretely, they remained in the
past_memberstable that's only meant for groups.Though it was not a bad bug; we're anyways not cleaning up old contacts.