Implement basic any-prefix/suffix matching for SearchConversations
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Sarah Jamie Lewis 2023-07-25 10:28:59 -07:00
parent 3f1e2d7a14
commit 3a7d2fce05
2 changed files with 7 additions and 1 deletions

View File

@ -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()

View File

@ -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 {