Skip to content

fix: recognize self addresses in various places (instead of just the "primary") - #8533

Open
hpk42 wants to merge 5 commits into
mainfrom
hpk/self-addr-recognition
Open

fix: recognize self addresses in various places (instead of just the "primary")#8533
hpk42 wants to merge 5 commits into
mainfrom
hpk/self-addr-recognition

Conversation

@hpk42

@hpk42 hpk42 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@hpk42
hpk42 force-pushed the hpk/self-addr-recognition branch from 2da385b to 11a09f7 Compare August 2, 2026 15:49
Comment thread src/mimefactory/mimefactory_tests.rs Outdated
Comment thread src/chat.rs Outdated
Comment thread src/mimefactory.rs
Comment thread src/contact.rs
let self_name2 = stock_str::self_msg(context);

if self_addr.contains(query)
if self_addrs.iter().any(|a| a.contains(query))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This change and the test in contacts_tests looks good.

@hpk42
hpk42 force-pushed the hpk/self-addr-recognition branch 2 times, most recently from d3b1853 to 8e8f019 Compare August 2, 2026 21:48
@hpk42
hpk42 force-pushed the hpk/self-addr-recognition branch from 8e8f019 to 55d30b1 Compare August 2, 2026 21:52
Comment thread src/receive_imf.rs
Comment on lines 3178 to -3180
} else {
let mut new_members: BTreeSet<ContactId>;
// True if a Delta Chat client has explicitly and really added our primary address to an

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this code block is untested, and writing a test seems involved (i tried).
I wonder if the original reason for this block has to do with pre-v2 versions?
You can also reach the block today i guess with someone sending from a stale member list (60 days no messages), so without member-timestamps, but it requires more conditions to cause this block to execute. And if we want to accept an explicit addition, we should still prefer later arriving member-timestamps and i am nto sure that's happening. It's all not too important i think, but if you have an easy answer, let me know. I just didn't bother with the test because the self-addr fix is small enough and straightfoward.

Comment thread src/chat.rs
Comment on lines -2854 to -2858
let from = context.get_primary_self_addr().await?;
let lowercase_from = from.to_lowercase();

recipients.retain(|x| x.to_lowercase() != lowercase_from);

@Hocuri Hocuri Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks like the self recipient may be added twice now under some circumstances? I just noticed that we don't have any tests at all for recipients, will write one

Edit: Nevermind, we do have some tests for it

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What we did not have is a test for not adding the self address twice in a group, or for not adding it at all when bcc_self is off. I wrote a test, and directly pushed it since @hpk42 said he won't engage much with DC development this week

@Hocuri Hocuri Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The self recipient may now be added twice if one of the group members' transports uses the same address as the self (primary) self address. This is such a rare case (and an already-broken setup) that it seems fine. For all other cases, the if id != ContactId::SELF checks in mimefactory.rs are most likely enough (confirmed by the test I just added).

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.

3 participants