ian
January 7, 2026, 9:18pm
4
Let me link all issues to a single place which are related to message deletion on the server (some of the threads may also contain outdated information):
No, it’s not a problem, the messages should be deleted eventually when phone is on and connection becomes available.
Check several days later that you don’t have extremely old messages, like from 2 days ago or something like this.
This is already how it works, if you delete messages on the server the client keeps it. Delta Chat downloads every message at most once, after that it does not matter if it exists on the server.
Related/enhancement to
Expected behavior
The additional idea here is the ability to set vanishing time for attachments (6M, 1Y, etc) so you will save a lot of space in you email postbox.
additionally we have so more granulated control like:
set the message size to delete (greater then)
choosing the type of attachment to delete (file, audio, media)
of cause setting the past time (6M, 1Y, etc)
…
Actual behavior
delete ALL messages automatically after some time or delete a message manually
First idea: Message deleting on demand
At the Moment on chatmail servers you can choose delete message automatically or after download. Especially if you receive many messages then your inbox gets very quickly full, so I asked me if it would be possible to implement something like delete messages on demand so if you inbox is like 80% it deletes older messages to make some space on the server even if they are not that old.
Second idea: Multi-device delete on download
As alternative I thought abo…
You can simply delete old message from IMAP server. Delta Chat does not read messages from the server more than once, it treats inbox as a feed rather than storage.
master ← delete-messages
opened 09:35PM - 23 Feb 20 UTC
Update: now this PR includes local message deletion as well.
----
Summary of… this PR:
- New setting `delete_server_after` is added, specifying the number of seconds after which the message should be deleted on the server. It is 0 (off) by default, 1 for "at once" option, > 1 is the number of seconds after which the message should be deleted. "1 second" is not an option.
- `delete_device_after` is planned for local deletion, but is not implemented in this PR
- A hidden entry is added to the chat for MDN messages, just like we did for `location.kml` messages before. It is needed to track MDN `server_uid`, so we can delete it on the server when it expires.
- `MarkseenMdnOnImap` job type is removed. Its name is misleading, it also moved MDNs to DeltaChat folder. Now that MDNs are treated as normal, but hidden, messages, they are moved by `MoveMsg` job.
- Deleting messages is prioritized over moving them. If we see an expired message, we delete it first and don't bother moving it.
- A new `MsgId.unlink()` method is added, clearing `server_uid` and `server_folder` for deleted messages. It is used in `DeleteMsgOnImap` job for messages that are displayed. For non-displayed messages (hidden or moved to the trash chat) we delete the database entry as before.
- `add_imap_deletion_jobs()` is a new method that adds deletion job for all expired messages. It is called before running IMAP jobs. If nothing happens for a long time it is possible to have one or two expired messages around on the server, but they will be deleted on the next app restart or IDLE interrupt. We don't start any timer to delete messages as soon as needed, it is planned for the future when threads are moved into rust.
- (Merged PR #1331) A new C function `dc_estimate_deletion_cnt` is added, estimating the number of messages that are going to be deleted on the server or locally right after setting `delete_server_after` or `delete_device_after` setting.
----
Here I am doing first batch of message deletion changes related to issues #1206 and #1308.
It was decided to implement two settings: one timer for message deletion on IMAP server and one timer for local message deletion.
In this PR I plan to implement IMAP message deletion only.
Initially, received message creates one or more database records in `msgs` table, sharing the same `rfc724_mid`. As message deletion is implemented now, when user deletes a message, it is moved into "trash" chat, which is never displayed, and a `DeleteMsgOnImap` job is created to remove the message from IMAP server.
A job checks if there are more database records pointing to the same `Message-ID`. If there are, it simply removes trash database record and does not delete the message on the server. Only when the last database record is deleted, message is removed from the server.
Since we want to remove displayed messages from IMAP now, we can no longer simply delete database records for them. So, for displayed messages, I implemented a `MsgId.unlink()` operation, which unlinks the message from the server message by setting `rfc724_mid` to empty string.
If such unlinked message is removed locally later, `DeleteMsgOnImap` job will detect it, and set result of IMAP message deletion operation to `ImapActionResult::AlreadyDone` and remove database record as usual.