@@ -316,10 +330,13 @@ export default {
type: Object,
required: true,
},
+ accountId: {
+ type: Number,
+ required: true,
+ },
},
data() {
return {
- modalQuery: '',
query: '',
debouncedSearchQuery: debouncePromise(this.sendQueryEvent, 700),
autocompleteRecipients: [],
@@ -329,8 +346,8 @@ export default {
searchInTo: null,
searchInCc: null,
searchInBcc: null,
- searchInSubject: true,
- searchInMessageBody: false,
+ searchInSubject: null,
+ searchInMessageBody: null,
searchFlags: [],
hasAttachments: false,
startDate: null,
@@ -360,13 +377,17 @@ export default {
return val !== ''
}).length > 0
},
+ searchBody() {
+ return this.$store.getters.getAccount(this.accountId)?.searchBody
+ },
filterData() {
return {
to: this.searchInTo !== null && this.searchInTo.length > 0 ? this.searchInTo[0].email : '',
from: this.searchInFrom !== null && this.searchInFrom.length > 0 ? this.searchInFrom[0].email : '',
cc: this.searchInCc !== null && this.searchInCc.length > 0 ? this.searchInCc[0].email : '',
bcc: this.searchInBcc !== null && this.searchInBcc.length > 0 ? this.searchInBcc[0].email : '',
- subject: this.searchInSubject && this.query.length > 1 ? this.query : '',
+ subject: this.searchInSubject !== null && this.searchInSubject.length > 1 ? this.searchInSubject : '',
+ body: this.searchInMessageBody !== null && this.searchInMessageBody.length > 1 ? this.searchInMessageBody : '',
tags: this.selectedTags.length > 0 ? this.selectedTags.map(item => item.id) : '',
flags: this.searchFlags.length > 0 ? this.searchFlags.map(item => item) : '',
start: this.prepareStart(),
@@ -377,7 +398,13 @@ export default {
searchQuery() {
let _search = ''
Object.entries(this.filterData).filter(([key, val]) => {
- if (val !== '' && val !== null) {
+ if (key === 'body') {
+ val.split(' ').forEach((word) => {
+ if (word !== '' && val !== null) {
+ _search += `${key}:${encodeURI(word)} `
+ }
+ })
+ } else if (val !== '' && val !== null) {
_search += `${key}:${encodeURI(val)} `
}
return val
@@ -388,9 +415,8 @@ export default {
},
watch: {
query() {
- if (this.query !== this.modalQuery) {
- this.modalQuery = this.query
- }
+ this.searchInMessageBody = this.searchBody ? this.query : null
+ this.searchInSubject = this.query
this.debouncedSearchQuery()
},
},
@@ -410,11 +436,7 @@ export default {
closeSearchModal() {
this.moreSearchActions = false
this.$nextTick(() => {
- if (this.query !== this.modalQuery) {
- this.query = this.modalQuery
- } else {
- this.sendQueryEvent()
- }
+ this.sendQueryEvent()
})
},
@@ -440,8 +462,8 @@ export default {
this.searchInTo = null
this.searchInCc = null
this.searchInBcc = null
- this.searchInSubject = true
- this.searchInMessageBody = false
+ this.searchInSubject = null
+ this.searchInMessageBody = null
this.searchFlags = []
this.startDate = null
this.endDate = null
diff --git a/src/components/SearchSettings.vue b/src/components/SearchSettings.vue
new file mode 100644
index 0000000000..b8c56ee0c0
--- /dev/null
+++ b/src/components/SearchSettings.vue
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Integration/Db/MailAccountTest.php b/tests/Integration/Db/MailAccountTest.php
index 71b6f44c1b..7d7fdaaa45 100644
--- a/tests/Integration/Db/MailAccountTest.php
+++ b/tests/Integration/Db/MailAccountTest.php
@@ -79,7 +79,8 @@ public function testToAPI() {
'quotaPercentage' => 10,
'trashRetentionDays' => 60,
'junkMailboxId' => null,
- 'snoozeMailboxId' => null
+ 'snoozeMailboxId' => null,
+ 'searchBody' => false
], $a->toJson());
}
@@ -115,6 +116,7 @@ public function testMailAccountConstruct() {
'trashRetentionDays' => 60,
'junkMailboxId' => null,
'snoozeMailboxId' => null,
+ 'searchBody' => false
];
$a = new MailAccount($expected);
// TODO: fix inconsistency
diff --git a/tests/Unit/Service/Search/MailSearchTest.php b/tests/Unit/Service/Search/MailSearchTest.php
index d89cc41583..b4cb29a938 100644
--- a/tests/Unit/Service/Search/MailSearchTest.php
+++ b/tests/Unit/Service/Search/MailSearchTest.php
@@ -184,8 +184,8 @@ public function testFindText() {
$mailbox->setSyncChangedToken('def');
$mailbox->setSyncVanishedToken('ghi');
$query = new SearchQuery();
- $query->addTextToken('my');
- $query->addTextToken('search');
+ $query->addBody('my');
+ $query->addBody('search');
$this->filterStringParser->expects($this->once())
->method('parse')
->with('my search')