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.
This commit is contained in:
Alexander Krotov
2020-02-24 02:36:18 +03:00
parent cc0f977d6f
commit 2cf9c68040
2 changed files with 44 additions and 2 deletions

View File

@@ -119,6 +119,23 @@ impl MsgId {
.ok();
}
/// Removes Message-ID, IMAP server UID, folder from the database
/// record.
///
/// It is used to avoid trying to remove the message from the
/// server multiple times when there are multiple message records
/// pointing to the same server UID.
pub(crate) fn unlink(self, context: &Context) -> sql::Result<()> {
sql::execute(
context,
&context.sql,
"UPDATE msgs \
SET rfc724_mid='', server_folder='', server_uid=0 \
WHERE id=?",
params![self],
)
}
/// Bad evil escape hatch.
///
/// Avoid using this, eventually types should be cleaned up enough