Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 19de9ff7 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #4799 from k9mail/fix_local_outbox

Fix local outbox
parents 81ec57aa 8ffd7e9c
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -960,10 +960,14 @@ public class LocalStore {
    }

    public long createLocalFolder(String folderName, FolderType type) throws MessagingException {
        return createLocalFolder(folderName, folderName, type);
    }

    public long createLocalFolder(String folderServerId, String folderName, FolderType type) throws MessagingException {
        return database.execute(true, (DbCallback<Long>) db -> {
            ContentValues values = new ContentValues();
            values.put("name", folderName);
            values.put("server_id", folderName);
            values.put("server_id", folderServerId);
            values.put("local_only", 1);
            values.put("type", FolderTypeConverter.toDatabaseFolderType(type));
            values.put("visible_limit", 0);
+2 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ class SpecialLocalFoldersCreator(

        val localStore = localStoreProvider.getInstance(account)

        account.outboxFolderId = localStore.createLocalFolder(OUTBOX_FOLDER_NAME, FolderType.OUTBOX)
        account.outboxFolderId = localStore.createLocalFolder(OUTBOX_SERVER_ID, OUTBOX_FOLDER_NAME, FolderType.OUTBOX)

        if (account.isPop3()) {
            check(account.draftsFolderId == null) { "Drafts folder was already set up" }
@@ -37,6 +37,7 @@ class SpecialLocalFoldersCreator(
    private fun Account.isPop3() = storeUri.startsWith("pop3")

    companion object {
        private const val OUTBOX_SERVER_ID = Account.OUTBOX
        private const val OUTBOX_FOLDER_NAME = Account.OUTBOX_NAME
        private const val DRAFTS_FOLDER_NAME = "Drafts"
        private const val SENT_FOLDER_NAME = "Sent"
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ class JmapAccountCreator(

    private fun createOutboxFolder(account: Account) {
        val localStore = localStoreProvider.getInstance(account)
        account.outboxFolderId = localStore.createLocalFolder(Account.OUTBOX_NAME, FolderType.OUTBOX)
        account.outboxFolderId = localStore.createLocalFolder(Account.OUTBOX, Account.OUTBOX_NAME, FolderType.OUTBOX)
    }

    private fun fetchFolderList(account: Account) {
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ import timber.log.Timber;


class StoreSchemaDefinition implements SchemaDefinition {
    static final int DB_VERSION = 76;
    static final int DB_VERSION = 77;

    private final MigrationsHelper migrationsHelper;

+17 −0
Original line number Diff line number Diff line
package com.fsck.k9.storage.migrations

import android.content.ContentValues
import android.database.sqlite.SQLiteDatabase

/**
 * Make sure local Outbox folder has correct 'server_id' value
 */
internal class MigrationTo77(private val db: SQLiteDatabase) {
    fun cleanUpOutboxServerId() {
        val values = ContentValues().apply {
            put("server_id", "K9MAIL_INTERNAL_OUTBOX")
        }

        db.update("folders", values, "name = 'Outbox' AND local_only = 1", null)
    }
}
Loading