Commit Graph
100 Commits
Author SHA1 Message Date
Alexander Krotov 3e2bfc35e3 Delete hidden expired messages
The condition remains from the time when expired messages were hidden
instead of being moved into trash chat. As a result, old hidden
messages, such as location messages, were not deleted.
2020-05-15 20:46:41 +03:00
Alexander Krotov 3ee81cbee0 Revert "imap: simplify select_folder() interface"
This reverts commit b614de2f80.
2020-05-13 11:36:33 +02:00
Alexander Krotov c185d5b0b5 Fix python lint error about unused format 2020-05-12 11:02:27 +02:00
Alexander Krotov cc56edc91d Log precheck_imf errors 2020-05-11 00:19:14 +03:00
Alexander Krotov c36227e2fc Better SMTP ErrorNetwork message
It uses stock string, just as for IMAP errors, and is distinguishable
from IMAP errors: protocol is specified in the error message now.
2020-05-10 23:24:03 +03:00
Alexander Krotov 2f6bae4e2a sql: do not send DC_EVENT_ERROR on database errors
These errors are usually just "database busy" errors, it is enough to
write them to the log instead of displaying to the user.
2020-05-10 17:51:01 +03:00
Alexander Krotov 0fefe11bfd Do not return "empty rfc724_mid" errors from rfc724_mid_cnt
This function should only return temporary errors, e.g. database errors,
as precheck_imf() and dc_receive_imf::add_parts() treat them as such,
retrying the fetch on failure. When permanent errors, like missing
Message-ID, are bubbled up, they cause infinite fetch loop.
2020-05-10 16:43:26 +03:00
Alexander Krotov 2dbb1bbbea Do not reply to hidden messages
Especially with read receipts, it is wrong, because they are never
encrypted and their Message-IDs are not known to other users in a group.
2020-05-09 19:11:23 +03:00
Alexander Krotov 5fd9b20213 Parse attachment filenames from Content-Type "name" attribute
Outlook specifies filename there and omits Content-Disposition.
2020-05-06 00:37:36 +03:00
Alexander Krotov 6543c7c26f fetch_single_msg: do not ignore dc_receive_imf errors
If error is ignored, the message will never be fetched again, even if
there was a database write error.

dc_receive_imf itself is modified to ignore unrecoverable errors, to
prevent endless refetching of incorrect messages.
2020-05-04 18:19:32 +03:00
Alexander Krotov 3035c8af30 Always describe the context of the displayed error 2020-05-04 16:35:42 +03:00
Alexander Krotov e8763e936d imap: simplify select_folder() interface
Accept AsRef<str> instead of Option<impl AsRef<str>>.

There is no need to pass None to force expunge anymore.
2020-04-30 23:48:41 +03:00
Alexander Krotov c41a6b87b8 imap: always close folder before selecting if expunge is needed 2020-04-30 23:48:41 +03:00
Alexander Krotov 46253039df Return BTreeMap instead of HashMap from get_info()
BTreeMap is sorted by keys when iterated, making it easier to find the
required line.
2020-04-28 21:26:04 +03:00
Alexander Krotov 46fb6a21ee job: perform no more than 20 IMAP jobs in a row
Let the thread load new messages. This may happen when user switches
the setting to delete messages on the server on and there are a lot of
messages to delete.
2020-04-25 01:43:35 +03:00
Alexander Krotov fc03f4c87a job: generate IMAP deletion jobs dynamically
This prevents generation of a large number of jobs when IMAP deletion
setting is enabled for the first time. Writing jobs to the database
locks it for readers and may cause UI freezing, because chatlist and
messages can't be read until all jobs are written.

Note that on failure job will be written to the database, to make sure
it is postponed instead of being retried immediately.
2020-04-24 21:06:57 +03:00
Alexander Krotov 502ec2a56f job: new API for dynamic job creation
Job::new() can be used to create jobs in-memory

Job.update() is replaced with Job.save() which can create new database
entries and consumes Job to avoid the need to update job ID after saving
it to the database.
2020-04-24 21:06:57 +03:00
Alexander Krotov 66d5c3f620 job: derive PartialEq for Action
This makes it possible to compare action priorities in Rust code.
2020-04-24 21:06:57 +03:00
Alexander Krotov 979d7c5625 Do not ignore database read errors in precheck_imf
If precheck_imf fails to check if message with the same rfc724_mid
already exists, the same message may be downloaded twice. Instead,
abort the whole operation and retry later.
2020-04-23 15:36:45 +03:00
Alexander Krotov 6c0dd8543d Delete expired messages instead of hiding them
For hidden messages, blobs are not deleted during housekeeping. To
actually free the space used by media files, messages should be moved to
trash instead of being hidden.
2020-04-20 02:29:55 +03:00
Alexander Krotov 8d2f526ee7 Fix a typo 2020-04-17 22:29:58 +03:00
Alexander Krotov 857a384d8b Switch to nightly-2020-03-12 2020-04-16 08:51:41 +02:00
Alexander Krotov 13dd88b7ad mimeparser: display inline images received from Thunderbird 2020-04-15 11:13:26 +02:00
Alexander Krotov e85cdc8c9f mimeparser: test parsing of inline images 2020-04-14 07:01:50 +02:00
Alexander Krotov 1760740a4c Parse inline attachments from non-DC email clients
Some mobile email clients, such as apple mail, attach or inline images
after description, just like Delta Chat. It is better to display them
instead of ignoring.
2020-04-14 07:01:50 +02:00
Alexander Krotov daf40fde82 mimefactory: use .next() instead of .nth(0) 2020-04-13 23:02:57 +03:00
Alexander Krotov e909b8199b lot: use as_deref() 2020-04-13 23:02:57 +03:00
Alexander Krotov ec089faf3a configure/auto_mozilla: remove indexing 2020-04-13 23:02:57 +03:00
Alexander Krotov 9fcb30ac33 Remove indexing in chatlist.get_summary() 2020-04-13 23:02:57 +03:00
Alexander Krotov cb92579461 Use slice patterns in EmailAddress::from_str() 2020-04-13 23:02:57 +03:00
Alexander Krotov 0327000f8d squash_attachment_parts: use slice patterns 2020-04-13 23:02:57 +03:00
Alexander Krotov 3a91c87c73 clippy: use as_deref() 2020-04-13 23:02:57 +03:00
Alexander Krotov db5b5d321b clippy: remove redundant imports 2020-04-13 23:02:57 +03:00
Alexander Krotov 76b7e7408a chatlist: remove indexing in get_{chat,msg}_id() 2020-04-13 23:02:57 +03:00
Alexander Krotov 324e5d0258 Use slice pattern to parse KML coordinates 2020-04-13 23:02:57 +03:00
Alexander Krotov d997bbc081 skip_forward_header: get rid of indexing with subslice patterns 2020-04-13 23:02:57 +03:00
Alexander Krotov 1c21d4f356 constants: remove unnecessary parenthesis
Rust warns about them now
2020-04-13 23:02:57 +03:00
Alexander Krotov 5f574cf283 get_next_media: replace indexing with .get() 2020-04-13 23:02:57 +03:00
Alexander Krotov 92f1e6da1e get_next_media: enumerate() instead of indexing 2020-04-13 23:02:57 +03:00
Alexander Krotov 24aa3c781b Remove indexing in Aheader::from_str 2020-04-13 23:02:57 +03:00
Alexander Krotov 32bd6109e3 Update rust-toolchain and proptest
It is required for stabilized subslice patterns.

proptest 0.9.6 fixes compatibility with the latest rustc nightly.
2020-04-13 23:02:57 +03:00
Alexander Krotov e9967c32e6 chat: filter parent messages by state instead of UID
Since introduction of server message deletion, message may not have
server UID even when it is not a draft or pending message. To handle
such messages correctly, we explicitly check message state.
2020-04-13 17:38:42 +02:00
Alexander Krotov 493a213d41 sql: move QueryReturnedNoRows and NULL handling into query_row_optional() 2020-04-13 17:38:42 +02:00
Alexander Krotov f65dbee74b Add basic test for ChatId.parent_is_encrypted() 2020-04-13 17:38:42 +02:00
Alexander Krotov f51fd1267f chat: move parent_query() and related methods from Chat to ChatId 2020-04-13 17:38:42 +02:00
Alexander Krotov d31265895d Update rPGP to 0.5.2 2020-04-03 12:57:13 +03:00
Alexander Krotov 9c2a3b8a82 Chatlist::try_load: make hide_device_expired_messages errors non-fatal 2020-04-03 12:13:42 +03:00
Alexander Krotov 916fab7d4b hide_device_expired_messages: allow missing self or device chat 2020-04-03 12:12:56 +03:00
Alexander Krotov 3163ef87c6 imap: display errors with {}, not {:?} 2020-04-01 23:27:15 +03:00
Alexander Krotov 1934181b52 Terminate new SQL statement lines with \
This way rustfmt can change indentation. However, care should be taken
to keep a space before each \
2020-04-01 20:06:27 +03:00
Alexander Krotov 1b815a7d96 Display an error if message cannot be trashed 2020-04-01 20:06:27 +03:00
Alexander Krotov 4e0a08106d ChatId.get_param: remove unnecessary type annotation 2020-04-01 20:06:27 +03:00
Alexander Krotov e8cc739fbd Reload chatlist when "delete_device_after" is set 2020-04-01 20:06:27 +03:00
Alexander Krotov fc57cbfb49 Refactor hiding of expired messages
Now there is only one function: hide_device_expired_messages().

If any messages are hidden event DC_EVENT_MSGS_CHANGED(0,0) is emitted
now, which is more correct than DC_EVENT_CHAT_MODIFIED and also triggers
chatlist reload.
2020-04-01 20:06:27 +03:00
Alexander Krotov 7522fec044 Do not emit "chat modified" events when loading chatlist
Otherwise chatlist will be loaded twice, once right after hiding expired
messages, and once in response to event emitted by try_load().
2020-04-01 20:06:27 +03:00
Alexander Krotov 237dabb907 Do not hide hidden messages in ChatId.delete_device_expired_messages()
This prevents infinite event loop, when chatlist is reloaded in response
to event, and event is emitted by hiding messages before chatlist reload.
2020-04-01 20:06:27 +03:00
Alexander Krotov 3686048ab6 chatlist: hide all expired messages before loading 2020-04-01 20:06:27 +03:00
Alexander Krotov 2bf4c5d7e7 Emit "chat modified" event when messages expire 2020-04-01 20:06:27 +03:00
Alexander Krotov 051d80b2f3 Move delete_device_expired_messages() to ChatId
This allows to check if chat is a self-talk or device chat.

Messages are deleted only in viewed chats now.
2020-04-01 20:06:27 +03:00
Alexander Krotov adaa1e856c chat: add ChatId.is_self_talk() and ChatId.is_device_talk() 2020-04-01 20:06:27 +03:00
Alexander Krotov 4daa57c98e delete_device_expired_messages: set text to DELETED for hidden messages
This makes debugging easier: DELETED messages should never be shown.
2020-04-01 20:06:27 +03:00
Alexander Krotov 7e67b2cbb3 Do not delete messages from special chats 2020-04-01 20:06:27 +03:00
Alexander Krotov 270d18a88a Move prune_tombstones() to sql:: and call from housekeeping() 2020-04-01 20:06:27 +03:00
Alexander Krotov 25f8a735a9 get_chat_msgs: remove locally expired messages
Expired messages are hidden right before retrieving messages from the
database, so expired messages are not shown to the user.
2020-04-01 20:06:27 +03:00
Alexander Krotov 9eb672ea17 Move removal of chat message tombstones to a separate function
DELETE operation may be slow compared to UPDATE. It is better to do in
a separate job.
2020-04-01 20:06:27 +03:00
Alexander Krotov 9febc762da Add chat::delete_device_expired_messages() function 2020-04-01 20:06:27 +03:00
Alexander Krotov 4b742c220c Add Context.get_config_delete_device_after() method
In contrast to get_config_delete_server_after(), value 1 does not mean
"delete at once", because it does not make sense to delete messages
immediately after receivning them.
2020-04-01 20:06:27 +03:00
Alexander Krotov 9d03d441e1 Add Config::DeleteDeviceAfter option 2020-04-01 20:06:27 +03:00
Alexander Krotov 4f73812673 Prioritize message deletion over message moving
If Delta Chat goes online and gets an expired message is in the Inbox,
it should delete it instead of moving and then deleting.
2020-04-01 20:06:27 +03:00
Alexander Krotov 33150615a1 Improve logging for server UID updates in precheck_imf()
Log all folders and UIDs and warn about UID changes without folder change.
2020-04-01 20:06:27 +03:00
Alexander Krotov 491f83c86d Remove ServerFolder and ServerUid job parameters
They were used by MarkseenMdnOnImap
2020-04-01 20:06:27 +03:00
Alexander Krotov 41f776763b Remove MarkseenMdnOnImap
MarkseenMdnOnImap stored server folder and UID which are never updated
by update_server_uid. Now hidden entries are created for MDNs, so they
should be handled as ordinary messages.
2020-04-01 20:06:27 +03:00
Alexander Krotov 65fdfac866 Remove unused dest_uid argument from Imap.mv()
It was always set to 0 because we don't know the destination UID.
2020-04-01 20:06:27 +03:00
Alexander Krotov cb0c00bc6d Log rfc724_mid in DeleteMsgOnImap 2020-04-01 20:06:27 +03:00
Alexander Krotov ad53678c19 Remove msgs.unlinked column
It is not used anymore.

Database version 64 migration introducing this column is also removed.
2020-04-01 20:06:27 +03:00
Alexander Krotov 62097765a6 update_server_uid: set server_uid even for unlinked messages
Sometimes message deletion job marks message as unlinked without
actually deleting it. It is possible if the message was already moved
into another folder, possibly by second device, but not detected there
yet. It should be detected later in the other folder, and the
server_uid in the database should be set.

Since introduction of add_imap_deletion_jobs() any expired message
record will be marked as unlinked eventually, because another message
deletion job will be scheduled even if update_server_uid() resurrects
the message once.
2020-04-01 20:06:27 +03:00
Alexander Krotov efb7280e99 Do not schedule delayed DeleteMsgOnImap jobs
All IMAP deletion jobs are scheduled either immediately, or later by
job::add_imap_deletion_jobs().
2020-04-01 20:06:27 +03:00
Alexander Krotov bdb2a47743 Revert "Automatically delete messages in 2 weeks window only"
This may result in messages not being deleted. Optimization and
traffic-saving is postponed for later, one idea is to optimize message
deletion to avoid checking if Message-ID on the server matches
Message-ID in the database.
2020-04-01 20:06:27 +03:00
Alexander Krotov c4677190be Postpone DeleteMsgOnImap on error
If job returns Status::Finished, it will be deleted. Then
add_imap_deletion_jobs will recreate it immediately if the message is
expired. To actually backoff the job, we should postpone it instead of
removing.
2020-04-01 20:06:27 +03:00
Alexander Krotov 055aba189c Automatically delete messages in 2 weeks window only
This is to avoid creating thousands of jobs when user enables
"delete_server_after" setting for the first time.

If device is offline for more than 2 weeks, some messages may not be
deleted.
2020-04-01 20:06:27 +03:00
Alexander Krotov 314c3d5e78 add_imap_deletion_jobs: check only for DeleteMsgOnImap jobs
Other jobs may have different meaning for foreign_id.

Also removed " \" at the end of lines.
2020-04-01 20:06:27 +03:00
Alexander Krotov 6db03356b5 Return AlreadyDone from Imap.delete_msg if message is gone
This way DeleteMsgOnImap will remove invalid server_uid from the database.
2020-04-01 20:06:27 +03:00
Alexander Krotov 28af919b09 Create DeleteMsgOnImap jobs before performing IMAP jobs
When "delete_server_after" setting is configured, postponed
DeleteMsgOnImap jobs are created for incoming messages.

This commit adds job::add_imap_deletion_jobs function which creates
DeleteMsgOnImap jobs right before performing IMAP jobs. This way even
messages that expired when the setting was disabled are going to be
deleted.

Job creation on message reception is unnecessary now, and even harmful
because it will create jobs with an expiration time which may later be
reduced. It is planned to be removed in following commits.
2020-04-01 20:06:27 +03:00
Alexander Krotov 8f7a456a39 Use 0 value for "delete_server_after" default.
Now 0 means "never delete", 1 means "delete at once" and other values
indicate the number of seconds after which them message should be
deleted from the server.

Configuration value interpretation is moved into
Context.get_config_delete_server_after() function.
2020-04-01 20:06:27 +03:00
Alexander Krotov 5b3bec1aac Create entries in msgs table for MDNs
At least one entry is required for DeleteMsgOnImap job. Additionally,
adding a hidden entry makes it possible to avoid redownloading the
message if it gets a new UID on the server.
2020-04-01 20:06:27 +03:00
Alexander Krotov f2aa17c9d0 Resultify MsgId.delete_from_db() 2020-04-01 20:06:27 +03:00
Alexander Krotov bc06b9e051 Do not send BCC-Self copy if we are going to remove it immediately 2020-04-01 20:06:27 +03:00
Alexander Krotov 6d216af507 Delete BCC-self messages after "delete_server_after" time 2020-04-01 20:06:27 +03:00
Alexander Krotov b2f1d9f376 Do not remove rfc724_mid for unlinked messages
Message-ID is used to send read receipts. Instead, add a separate
"unlinked" column.
2020-04-01 20:06:27 +03:00
Alexander Krotov a653e469f2 Add user-configurable option "delete_server_after"
The option sets timer in seconds after which all parts of the message
are deleted from the server.
2020-04-01 20:06:27 +03:00
Alexander Krotov 4f4241ba3a dc_receive_imf: delete all message parts if message should be deleted
DeleteMsgOnImap deletes files from the server only when the last part
is deleted. Removing only the first part of the hidden or trashed
message does not result in message deletion.
2020-04-01 20:06:27 +03:00
Alexander Krotov 2cf9c68040 Implement MsgId.unlink() and use it in DeleteMsgOnImap
Currently only trashed or hidden messages are deleted by
DeleteMsgOnImap, so it is safe to remove database records.

It is planned to delete messages on IMAP server after
user-configurable time to cleanup the server even for messages
displayed in chats. For such messages, we unlink them from the
Message-ID, but keep the database record to display them.
2020-04-01 20:06:27 +03:00
Alexander Krotov cc0f977d6f Document rfc724_mid_cnt 2020-04-01 20:06:27 +03:00
Alexander Krotov 7879952fde Delete MDNs first in MsgId.delete_from_db() 2020-04-01 20:06:27 +03:00
Alexander Krotov 4452cab987 Turn Message::Delete_from_db into MsgId method 2020-04-01 20:06:27 +03:00
Alexander Krotov 98bd64621a Refactor Imap.delete_msg() error handling
Mutable UID reference is removed. Instead, ImapActionResult is
returned immediately.

If message has changed and UID does not correspond to expected
message, ImapActionResult::Failed is returned. Temprorary IMAP errors
result in ImapActionResult::RetryLater.

On the job side, ImapActionResult::RetryLater does not result in
immediate job retry anymore. Instead, job is retried with a backoff.
2020-04-01 20:06:27 +03:00
Alexander Krotov c1c769ceb0 Add MsgId.trash() and use it to delete messages locally
In addition to moving the message into trash chat, this function
removes message text to make sure the message does not remain in the
database. Only the information necessary to delete message from the
server and avoid redownloading it should be kept, such as Message-Id
and IMAP UID.
2020-04-01 20:06:27 +03:00
Alexander Krotov d64e55c66f delete_msgs: remove explicit .iter() 2020-04-01 20:06:27 +03:00
Alexander Krotov 76fc84be37 job: document DeleteMsgOnImap 2020-04-01 20:06:27 +03:00
Alexander Krotov d78ea882c8 Update mailparse to 0.12 2020-03-31 18:11:44 +02:00