deltachat / deltachat-core-rust

Delta Chat Rust Core library, used by Android/iOS/desktop apps, bindings and bots 📧
https://delta.chat/en/contribute
Other
636 stars 81 forks source link

duplicated contacts in contact list #448

Closed r10s closed 4 years ago

r10s commented 4 years ago

the contact list shows several contacts multiple times.

not yet sure if they're really duplicated in the database of if dc_get_contacts() is buggy. EDIT: they're really duplicated in the database. eg. times several bob@librechat.net in my case (nb: the "original" entry has
id=5077, origin=1048576=0x1000000=DC_ORIGIN_SECUREJOIN_INVITED, name=Bob; the duplicates have
id>7000, origin=524288=0x80000=DC_ORIGIN_ADRESS_BOOK) and name set to email address (not empty).

r10s commented 4 years ago

so, might be that dc_add_address_book() is buggy.

dignifiedquire commented 4 years ago

I found a bug in add_or_create_contact

r10s commented 4 years ago

i investigated a bit:

the problem is a contact in the database that has an unknown origin - for whatever reason, however, this can easily happen (in my case, the contact has the origin 0x100000 which was probably used some time ago)

as a result, Contact::add_or_lookup() fails when parsing the returned row at let row_origin = row.get(3)?; which makes the whole SELECT-statement failing - the following lines assume the contact just does not exist and insert a duplicate then, which is bad.

i suggest that impl FromSql for Origin should not result in an error but just return Unknown. this would also fix the problem for similar situations.