Skip to content

Contact deletion may delete a contact with existing messages #4792

Open
@link2xt

Description

@link2xt

Here SQL code checks that the contact is not a member of any chat:
https://github.com/deltachat/deltachat-core-rust/blob/a119b24eeb60d38aa95f8cadbd1727eb3b64d9ef/src/contact.rs#L1062-L1066

However, even if the contact is not a member of the chat, they may be a former member of the chat and have messages there. In this case these messages will start pointing to non-existent contact. The contact ID may still be used in msgs.from_id, msgs.to_id, locations.from_id, msgs_mdns.contact_id. Address may still be in acpeerstates.addr and acpeerstates.verifier.

See previous comment here: #4791 (review)

Maintaining the code checking that contact is not referenced from anywhere is error-prone. Trying to delete the contact in housekeeping as proposed in #4775 may never actually delete the contact if they sent us a message in another chat, tried to add us to the group, sent us a location etc.

As an alternative solution, maybe we should actually never delete an account, but anonymize it instead, similarly to how Discourse and GitHub do this when user deletes an account? As long as we are not going to write to this contact, we can replace its address, name, authname and hide it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions