mirror of
https://github.com/chatmail/core.git
synced 2026-05-24 09:16:32 +03:00
fix: Correctly delete unneeded messages on the server; Remove "Delete Messages from Server" (delete_server_after) config option (#8240)
Fix https://github.com/chatmail/core/issues/8195 Supersedes https://github.com/chatmail/core/pull/8217 The most interesting change is in `delete_expired_imap_messages()` because there, messages are marked for deletion on single-device chatmail profiles. The logic in `delete_expired_imap_messages()` was wrong before, and pre-messages were not deleted at all. This is fixed by also querying `pre_rfc724_mid` in addition to `rfc724_mid` from the `msgs` table. In order not to make the SQL statement too complex, I split it into two. WRT tests: - `test_immediate_autodelete()` tests the auto-deletion; `test_imap_autodelete_fully_downloaded_msg()` tests that even for a message that is split into pre- and post-message, both messages are deleted. - A lot of tests test that if bcc_self is on, messages are not auto-deleted. E.g. `test_one_account_send_bcc_setting()` and `test_markseen_message_and_mdn()` relies on the fact that messages stay on the server when bcc_self is on. - Unfortunately, it is not possible to test that messages are only deleted for chatmail servers, because we don't have any tests that use a non-chatmail server.
This commit is contained in:
@@ -4,39 +4,29 @@ from deltachat_rpc_client import EventType
|
||||
from deltachat_rpc_client.const import MessageState
|
||||
|
||||
|
||||
def test_bcc_self_delete_server_after_defaults(acfactory):
|
||||
"""Test default values for bcc_self and delete_server_after."""
|
||||
def test_bcc_self_is_enabled_when_setting_up_second_device(acfactory):
|
||||
ac = acfactory.get_online_account()
|
||||
|
||||
# Initially after getting online
|
||||
# the setting bcc_self is set to 0 because there is only one device
|
||||
# and delete_server_after is "1", meaning immediate deletion.
|
||||
assert ac.get_config("bcc_self") == "0"
|
||||
assert ac.get_config("delete_server_after") == "1"
|
||||
|
||||
# Setup a second device.
|
||||
ac_clone = ac.clone()
|
||||
ac_clone.bring_online()
|
||||
|
||||
# Second device setup
|
||||
# enables bcc_self and changes default delete_server_after.
|
||||
# Second device setup enables bcc_self.
|
||||
assert ac.get_config("bcc_self") == "1"
|
||||
assert ac.get_config("delete_server_after") == "0"
|
||||
|
||||
assert ac_clone.get_config("bcc_self") == "1"
|
||||
assert ac_clone.get_config("delete_server_after") == "0"
|
||||
|
||||
# Manually disabling bcc_self
|
||||
# also restores the default for delete_server_after.
|
||||
# Test manually disabling bcc_self
|
||||
ac.set_config("bcc_self", "0")
|
||||
assert ac.get_config("bcc_self") == "0"
|
||||
assert ac.get_config("delete_server_after") == "1"
|
||||
|
||||
# Cloning the account again enables bcc_self
|
||||
# Cloning the account again enables bcc_self again
|
||||
# even though it was manually disabled.
|
||||
ac_clone = ac.clone()
|
||||
assert ac.get_config("bcc_self") == "1"
|
||||
assert ac.get_config("delete_server_after") == "0"
|
||||
|
||||
|
||||
def test_one_account_send_bcc_setting(acfactory, log, direct_imap):
|
||||
|
||||
Reference in New Issue
Block a user