Remove StoreConfig.isRemoteSearchFullText()
This commit is contained in:
parent
1858986fc4
commit
d7d1fe0c0e
11 changed files with 30 additions and 22 deletions
|
@ -476,7 +476,9 @@ public class MessagingController {
|
|||
|
||||
Backend backend = getBackend(acct);
|
||||
|
||||
List<String> messageServerIds = backend.search(folderServerId, query, requiredFlags, forbiddenFlags);
|
||||
boolean performFullTextSearch = acct.isRemoteSearchFullText();
|
||||
List<String> messageServerIds = backend.search(folderServerId, query, requiredFlags, forbiddenFlags,
|
||||
performFullTextSearch);
|
||||
|
||||
Timber.i("Remote search got %d results", messageServerIds.size());
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
|||
|
||||
when(localNewMessage1.getUid()).thenReturn("newMessageUid1");
|
||||
when(localNewMessage2.getUid()).thenReturn("newMessageUid2");
|
||||
when(backend.search(eq(FOLDER_NAME), anyString(), nullable(Set.class), nullable(Set.class)))
|
||||
when(backend.search(eq(FOLDER_NAME), anyString(), nullable(Set.class), nullable(Set.class), eq(false)))
|
||||
.thenReturn(remoteMessages);
|
||||
when(localFolder.extractNewMessages(ArgumentMatchers.<String>anyList())).thenReturn(newRemoteMessages);
|
||||
when(localFolder.getMessage("newMessageUid1")).thenReturn(localNewMessage1);
|
||||
|
@ -291,7 +291,7 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
|||
|
||||
controller.searchRemoteMessagesSynchronous(ACCOUNT_UUID, FOLDER_NAME, "query", reqFlags, forbiddenFlags, listener);
|
||||
|
||||
verify(backend).search(FOLDER_NAME, "query", reqFlags, forbiddenFlags);
|
||||
verify(backend).search(FOLDER_NAME, "query", reqFlags, forbiddenFlags, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -342,7 +342,7 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
|||
@Test
|
||||
public void searchRemoteMessagesSynchronous_shouldNotifyOnFailure() throws Exception {
|
||||
setupRemoteSearch();
|
||||
when(backend.search(anyString(), anyString(), nullable(Set.class), nullable(Set.class)))
|
||||
when(backend.search(anyString(), anyString(), nullable(Set.class), nullable(Set.class), eq(false)))
|
||||
.thenThrow(new MessagingException("Test"));
|
||||
|
||||
controller.searchRemoteMessagesSynchronous(ACCOUNT_UUID, FOLDER_NAME, "query", reqFlags, forbiddenFlags, listener);
|
||||
|
@ -353,7 +353,7 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
|||
@Test
|
||||
public void searchRemoteMessagesSynchronous_shouldNotifyOnFinish() throws Exception {
|
||||
setupRemoteSearch();
|
||||
when(backend.search(anyString(), nullable(String.class), nullable(Set.class), nullable(Set.class)))
|
||||
when(backend.search(anyString(), nullable(String.class), nullable(Set.class), nullable(Set.class), eq(false)))
|
||||
.thenThrow(new MessagingException("Test"));
|
||||
|
||||
controller.searchRemoteMessagesSynchronous(ACCOUNT_UUID, FOLDER_NAME, "query", reqFlags, forbiddenFlags, listener);
|
||||
|
|
|
@ -71,7 +71,8 @@ interface Backend {
|
|||
folderServerId: String,
|
||||
query: String?,
|
||||
requiredFlags: Set<Flag>?,
|
||||
forbiddenFlags: Set<Flag>?
|
||||
forbiddenFlags: Set<Flag>?,
|
||||
performFullTextSearch: Boolean
|
||||
): List<String>
|
||||
|
||||
@Throws(MessagingException::class)
|
||||
|
|
|
@ -9,11 +9,12 @@ internal class CommandSearch(private val imapStore: ImapStore) {
|
|||
folderServerId: String,
|
||||
query: String?,
|
||||
requiredFlags: Set<Flag>?,
|
||||
forbiddenFlags: Set<Flag>?
|
||||
forbiddenFlags: Set<Flag>?,
|
||||
performFullTextSearch: Boolean
|
||||
): List<String> {
|
||||
val folder = imapStore.getFolder(folderServerId)
|
||||
try {
|
||||
return folder.search(query, requiredFlags, forbiddenFlags)
|
||||
return folder.search(query, requiredFlags, forbiddenFlags, performFullTextSearch)
|
||||
.sortedWith(UidReverseComparator())
|
||||
.map { it.uid }
|
||||
} finally {
|
||||
|
|
|
@ -182,9 +182,9 @@ public class ImapBackend implements Backend {
|
|||
@NotNull
|
||||
@Override
|
||||
public List<String> search(@NotNull String folderServerId, @Nullable String query,
|
||||
@Nullable Set<? extends Flag> requiredFlags, @Nullable Set<? extends Flag> forbiddenFlags)
|
||||
throws MessagingException {
|
||||
return commandSearch.search(folderServerId, query, requiredFlags, forbiddenFlags);
|
||||
@Nullable Set<? extends Flag> requiredFlags, @Nullable Set<? extends Flag> forbiddenFlags,
|
||||
boolean performFullTextSearch) {
|
||||
return commandSearch.search(folderServerId, query, requiredFlags, forbiddenFlags, performFullTextSearch);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
|
|
@ -99,7 +99,13 @@ class JmapBackend(
|
|||
return messageServerIds.associateWith { it }
|
||||
}
|
||||
|
||||
override fun search(folderServerId: String, query: String?, requiredFlags: Set<Flag>?, forbiddenFlags: Set<Flag>?): List<String> {
|
||||
override fun search(
|
||||
folderServerId: String,
|
||||
query: String?,
|
||||
requiredFlags: Set<Flag>?,
|
||||
forbiddenFlags: Set<Flag>?,
|
||||
performFullTextSearch: Boolean
|
||||
): List<String> {
|
||||
throw UnsupportedOperationException("not implemented")
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,8 @@ class Pop3Backend(
|
|||
folderServerId: String,
|
||||
query: String?,
|
||||
requiredFlags: Set<Flag>?,
|
||||
forbiddenFlags: Set<Flag>?
|
||||
forbiddenFlags: Set<Flag>?,
|
||||
performFullTextSearch: Boolean
|
||||
): List<String> {
|
||||
throw UnsupportedOperationException("not supported")
|
||||
}
|
||||
|
|
|
@ -107,7 +107,8 @@ class WebDavBackend(
|
|||
folderServerId: String,
|
||||
query: String?,
|
||||
requiredFlags: Set<Flag>?,
|
||||
forbiddenFlags: Set<Flag>?
|
||||
forbiddenFlags: Set<Flag>?,
|
||||
performFullTextSearch: Boolean
|
||||
): List<String> {
|
||||
throw UnsupportedOperationException("not supported")
|
||||
}
|
||||
|
|
|
@ -10,6 +10,4 @@ public interface StoreConfig {
|
|||
String getDraftsFolder();
|
||||
|
||||
int getMaximumAutoDownloadMessageSize();
|
||||
|
||||
boolean isRemoteSearchFullText();
|
||||
}
|
||||
|
|
|
@ -1332,7 +1332,7 @@ public class ImapFolder {
|
|||
* @throws MessagingException On any error.
|
||||
*/
|
||||
public List<ImapMessage> search(final String queryString, final Set<Flag> requiredFlags,
|
||||
final Set<Flag> forbiddenFlags) throws MessagingException {
|
||||
final Set<Flag> forbiddenFlags, boolean performFullTextSearch) throws MessagingException {
|
||||
|
||||
try {
|
||||
open(OPEN_MODE_RO);
|
||||
|
@ -1342,7 +1342,7 @@ public class ImapFolder {
|
|||
|
||||
String searchCommand = new UidSearchCommandBuilder()
|
||||
.queryString(queryString)
|
||||
.performFullTextSearch(store.getStoreConfig().isRemoteSearchFullText())
|
||||
.performFullTextSearch(performFullTextSearch)
|
||||
.requiredFlags(requiredFlags)
|
||||
.forbiddenFlags(forbiddenFlags)
|
||||
.build();
|
||||
|
|
|
@ -969,10 +969,9 @@ public class ImapFolderTest {
|
|||
public void search_withFullTextSearchEnabled_shouldIssueRespectiveCommand() throws Exception {
|
||||
ImapFolder folder = createFolder("Folder");
|
||||
prepareImapFolderForOpen(OPEN_MODE_RO);
|
||||
when(storeConfig.isRemoteSearchFullText()).thenReturn(true);
|
||||
setupUidSearchResponses("1 OK SEARCH completed");
|
||||
|
||||
folder.search("query", newSet(Flag.SEEN), Collections.<Flag>emptySet());
|
||||
folder.search("query", newSet(Flag.SEEN), Collections.<Flag>emptySet(), true);
|
||||
|
||||
assertCommandIssued("UID SEARCH TEXT \"query\" SEEN");
|
||||
}
|
||||
|
@ -981,10 +980,9 @@ public class ImapFolderTest {
|
|||
public void search_withFullTextSearchDisabled_shouldIssueRespectiveCommand() throws Exception {
|
||||
ImapFolder folder = createFolder("Folder");
|
||||
prepareImapFolderForOpen(OPEN_MODE_RO);
|
||||
when(storeConfig.isRemoteSearchFullText()).thenReturn(false);
|
||||
setupUidSearchResponses("1 OK SEARCH completed");
|
||||
|
||||
folder.search("query", Collections.<Flag>emptySet(), Collections.<Flag>emptySet());
|
||||
folder.search("query", Collections.<Flag>emptySet(), Collections.<Flag>emptySet(), false);
|
||||
|
||||
assertCommandIssued("UID SEARCH OR SUBJECT \"query\" FROM \"query\"");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue