-
-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Remove unused contacts in housekeeping #4791
Conversation
Remove contacts that don't have associated chats in housekeeping.
context | ||
.sql | ||
.execute( | ||
"DELETE FROM contacts WHERE origin=? AND id NOT IN (SELECT contact_id FROM chats_contacts);", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented here #4785 (comment) that it is probably better to remove the contact before deleting files so avatar gets deleted in a single housekeeping run. It is marked as resolved, but seems to be lost during rebase.
the description is misleading - in that generality, it sounds like a non-goal and i just wanted to comment :) by reading the code, however, i realised that it is only about contacts that were already manually deleted by the user before :) as this still sounds fragile, i'd enhance the test to add two contact without a chat before housekeeping:
for blocked contacts, things seem to be fine, they do not use the "origin" (so, blocked contacts do not get the origin "Hidden") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one more problem. What if the contact is removed from all chats, but still has messages where they are author? In this case messages will not be associated to any existing contact anymore.
I guess, the problem is that we have two different requirements for the contact deletion. For the UI, contact deletion should only hide contacts for creating new chats and for the bot (where this issue arose from) deleting contacts should delete everything associated with him. |
I opened an issue #4792 as this is a problem not only for housekeeping, but for contact deletion as well. |
There may be messages from this user in other chats, e.g. if someone tries to add the bot to a group. |
Remove contacts that don't have associated chats in housekeeping.