Replace Account.getOutboxFolder() with Account.getOutboxFolderId()
This commit is contained in:
parent
0b939eee25
commit
789769ef39
8 changed files with 17 additions and 28 deletions
|
@ -602,10 +602,6 @@ public class Account implements BaseAccount {
|
|||
return spamFolderSelection;
|
||||
}
|
||||
|
||||
public String getOutboxFolder() {
|
||||
return OUTBOX;
|
||||
}
|
||||
|
||||
public Long getOutboxFolderId() {
|
||||
// FIXME: Persist folder ID instead of folder server ID
|
||||
LocalStoreProvider localStoreProvider = DI.get(LocalStoreProvider.class);
|
||||
|
|
|
@ -625,8 +625,11 @@ public class MessagingController {
|
|||
commandException = e;
|
||||
}
|
||||
|
||||
long folderId = getFolderIdOrThrow(account, folderServerId);
|
||||
|
||||
// We don't ever sync the Outbox
|
||||
if (folderServerId.equals(account.getOutboxFolder())) {
|
||||
Long outboxFolderId = account.getOutboxFolderId();
|
||||
if (outboxFolderId != null && outboxFolderId == folderId) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -639,7 +642,6 @@ public class MessagingController {
|
|||
String rootMessage = getRootCauseMessage(commandException);
|
||||
Timber.e("Root cause failure in %s:%s was '%s'", account.getDescription(), folderServerId, rootMessage);
|
||||
updateFolderStatus(account, folderServerId, rootMessage);
|
||||
long folderId = getFolderIdOrThrow(account, folderServerId);
|
||||
listener.synchronizeMailboxFailed(account, folderId, rootMessage);
|
||||
}
|
||||
}
|
||||
|
@ -1373,7 +1375,7 @@ public class MessagingController {
|
|||
MessagingListener listener) {
|
||||
try {
|
||||
LocalStore localStore = localStoreProvider.getInstance(account);
|
||||
LocalFolder localFolder = localStore.getFolder(account.getOutboxFolder());
|
||||
LocalFolder localFolder = localStore.getFolder(account.getOutboxFolderId());
|
||||
localFolder.open();
|
||||
localFolder.appendMessages(Collections.singletonList(message));
|
||||
LocalMessage localMessage = localFolder.getMessage(message.getUid());
|
||||
|
@ -1453,8 +1455,7 @@ public class MessagingController {
|
|||
private boolean messagesPendingSend(final Account account) {
|
||||
LocalFolder localFolder = null;
|
||||
try {
|
||||
localFolder = localStoreProvider.getInstance(account).getFolder(
|
||||
account.getOutboxFolder());
|
||||
localFolder = localStoreProvider.getInstance(account).getFolder(account.getOutboxFolderId());
|
||||
if (!localFolder.exists()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1483,7 +1484,7 @@ public class MessagingController {
|
|||
try {
|
||||
LocalStore localStore = localStoreProvider.getInstance(account);
|
||||
OutboxStateRepository outboxStateRepository = localStore.getOutboxStateRepository();
|
||||
localFolder = localStore.getFolder(account.getOutboxFolder());
|
||||
localFolder = localStore.getFolder(account.getOutboxFolderId());
|
||||
if (!localFolder.exists()) {
|
||||
Timber.v("Outbox does not exist");
|
||||
return;
|
||||
|
@ -1507,8 +1508,7 @@ public class MessagingController {
|
|||
fp.add(FetchProfile.Item.ENVELOPE);
|
||||
fp.add(FetchProfile.Item.BODY);
|
||||
|
||||
Timber.i("Scanning folder '%s' (%d) for messages to send",
|
||||
account.getOutboxFolder(), localFolder.getDatabaseId());
|
||||
Timber.i("Scanning Outbox folder for messages to send");
|
||||
|
||||
Backend backend = getBackend(account);
|
||||
|
||||
|
@ -2020,6 +2020,7 @@ public class MessagingController {
|
|||
LocalStore localStore = localStoreProvider.getInstance(account);
|
||||
localFolder = localStore.getFolder(folder);
|
||||
localFolder.open();
|
||||
long folderId = localFolder.getDatabaseId();
|
||||
|
||||
Map<String, String> uidMap = null;
|
||||
if (folder.equals(account.getTrashFolder()) || !account.hasTrashFolder() ||
|
||||
|
@ -2051,7 +2052,8 @@ public class MessagingController {
|
|||
|
||||
Timber.d("Delete policy for account %s is %s", account.getDescription(), account.getDeletePolicy());
|
||||
|
||||
if (folder.equals(account.getOutboxFolder())) {
|
||||
Long outboxFolderId = account.getOutboxFolderId();
|
||||
if (outboxFolderId != null && folderId == outboxFolderId) {
|
||||
for (Message message : messages) {
|
||||
// If the message was in the Outbox, then it has been copied to local Trash, and has
|
||||
// to be copied to remote trash
|
||||
|
@ -2062,7 +2064,6 @@ public class MessagingController {
|
|||
processPendingCommands(account);
|
||||
} else if (!syncedMessageUids.isEmpty()) {
|
||||
if (account.getDeletePolicy() == DeletePolicy.ON_DELETE) {
|
||||
long folderId = localFolder.getDatabaseId();
|
||||
if (!account.hasTrashFolder() || folder.equals(account.getTrashFolder()) ||
|
||||
!backend.isDeleteMoveToTrash()) {
|
||||
queueDelete(account, folderId, syncedMessageUids);
|
||||
|
|
|
@ -269,8 +269,8 @@ public class LocalFolder {
|
|||
public Boolean doDbWork(final SQLiteDatabase db) throws WrappedException {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.rawQuery("SELECT id FROM folders where folders.server_id = ?",
|
||||
new String[] { LocalFolder.this.getServerId() });
|
||||
cursor = db.rawQuery("SELECT id FROM folders where id = ?",
|
||||
new String[] { Long.toString(getDatabaseId()) });
|
||||
if (cursor.moveToFirst()) {
|
||||
int folderId = cursor.getInt(0);
|
||||
return (folderId > 0);
|
||||
|
|
|
@ -367,7 +367,7 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
|||
|
||||
@Test
|
||||
public void sendPendingMessagesSynchronous_withNonExistentOutbox_shouldNotStartSync() throws MessagingException {
|
||||
when(account.getOutboxFolder()).thenReturn(FOLDER_NAME);
|
||||
when(account.getOutboxFolderId()).thenReturn(FOLDER_ID);
|
||||
when(localFolder.exists()).thenReturn(false);
|
||||
controller.addListener(listener);
|
||||
|
||||
|
@ -454,7 +454,7 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
|||
}
|
||||
|
||||
private void setupAccountWithMessageToSend() throws MessagingException {
|
||||
when(account.getOutboxFolder()).thenReturn(FOLDER_NAME);
|
||||
when(account.getOutboxFolderId()).thenReturn(FOLDER_ID);
|
||||
account.setSentFolder(SENT_FOLDER_NAME, SpecialFolderSelection.AUTOMATIC);
|
||||
when(localStore.getFolder(SENT_FOLDER_NAME)).thenReturn(sentFolder);
|
||||
when(sentFolder.getDatabaseId()).thenReturn(1L);
|
||||
|
|
|
@ -135,7 +135,7 @@ public class SyncNotificationsTest extends RobolectricTest {
|
|||
Account account = mock(Account.class);
|
||||
when(account.getAccountNumber()).thenReturn(ACCOUNT_NUMBER);
|
||||
when(account.getDescription()).thenReturn(ACCOUNT_NAME);
|
||||
when(account.getOutboxFolder()).thenReturn("OUTBOX");
|
||||
when(account.getOutboxFolderId()).thenReturn(33L);
|
||||
|
||||
return account;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ internal object MigrationTo67 {
|
|||
|
||||
val account = migrationsHelper.account
|
||||
setFolderType(db, account.inboxFolder, "inbox")
|
||||
setFolderType(db, account.outboxFolder, "outbox")
|
||||
setFolderType(db, "K9MAIL_INTERNAL_OUTBOX", "outbox")
|
||||
setFolderType(db, account.trashFolder, "trash")
|
||||
setFolderType(db, account.draftsFolder, "drafts")
|
||||
setFolderType(db, account.spamFolder, "spam")
|
||||
|
|
|
@ -395,7 +395,6 @@ public class StoreSchemaDefinitionTest extends K9RobolectricTest {
|
|||
private Account createAccount() {
|
||||
Account account = mock(Account.class);
|
||||
when(account.getInboxFolder()).thenReturn("Inbox");
|
||||
when(account.getOutboxFolder()).thenReturn(Account.OUTBOX);
|
||||
when(account.getTrashFolder()).thenReturn("Trash");
|
||||
when(account.getDraftsFolder()).thenReturn("Drafts");
|
||||
when(account.getSpamFolder()).thenReturn("Spam");
|
||||
|
|
|
@ -186,13 +186,6 @@ public class ImapStore {
|
|||
|
||||
if (ImapFolder.INBOX.equalsIgnoreCase(serverId)) {
|
||||
continue;
|
||||
} else if (serverId.equals("K9MAIL_INTERNAL_OUTBOX")) {
|
||||
/*
|
||||
* There is a folder on the server with the same name as our local
|
||||
* outbox. Until we have a good plan to deal with this situation
|
||||
* we simply ignore the folder on the server.
|
||||
*/
|
||||
continue;
|
||||
} else if (listResponse.hasAttribute("\\NoSelect")) {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue