Merge pull request 'Implement basic any-prefix/suffix matching for SearchConversations' (#524) from conversation_search into master
continuous-integration/drone/push Build is pending
Details
continuous-integration/drone/push Build is pending
Details
Reviewed-on: #524 Reviewed-by: Dan Ballard <dan@openprivacy.ca>
This commit is contained in:
commit
a47d916eac
|
@ -856,6 +856,12 @@ func (cp *cwtchPeer) doSearch(ctx context.Context, searchID string, pattern stri
|
|||
// Note: This should note be used to index a list as the ID is not expected to be tied to absolute position
|
||||
// in the table (e.g. deleted messages, expired messages, etc.)
|
||||
func (cp *cwtchPeer) SearchConversations(pattern string) string {
|
||||
|
||||
// TODO: For now, we simply surround the pattern with the sqlite LIKE syntax for matching any prefix, and any suffix
|
||||
// At some point we would like to extend this patternt to support e.g. searching a specific conversation, or
|
||||
// searching for particular types of message.
|
||||
pattern = fmt.Sprintf("%%%v%%", pattern)
|
||||
|
||||
// we need this lock here to prevent weirdness happening when reassigning cp.cancelSearchContext
|
||||
cp.mutex.Lock()
|
||||
defer cp.mutex.Unlock()
|
||||
|
|
|
@ -166,7 +166,7 @@ func TestFileSharing(t *testing.T) {
|
|||
|
||||
// Wait for the messages to arrive...
|
||||
time.Sleep(time.Second * 20)
|
||||
alice.SearchConversations("%test%")
|
||||
alice.SearchConversations("test")
|
||||
|
||||
results := 0
|
||||
for {
|
||||
|
|
Loading…
Reference in New Issue