Skip to content

Commit 22c047d

Browse files
authored
Add support for message filters (#33)
1 parent c05bd25 commit 22c047d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/GetStream/StreamChat/Client.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ public function verifyWebhook($requestBody, $XSignature)
766766

767767
/**
768768
* @param array $filterConditions
769-
* @param string $query
769+
* @param mixed $query // string query or filters for messages
770770
* @param array $options
771771
* @return mixed
772772
* @throws StreamException
@@ -777,7 +777,12 @@ public function search($filterConditions, $query, $options=null)
777777
$options = array();
778778
}
779779
$options['filter_conditions'] = $filterConditions;
780-
$options['query'] = $query;
780+
if(is_string($query)) {
781+
$options['query'] = $query;
782+
} else {
783+
$options['message_filter_conditions'] = $query;
784+
}
785+
781786
return $this->get("search", ["payload" => json_encode($options)]);
782787
}
783788

tests/integration/IntegrationTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,13 @@ public function testSearch(){
585585
foreach($response['results'] as $message){
586586
$this->assertFalse(strpos($message['message']['text'], $query));
587587
}
588+
589+
$response = $this->client->search(
590+
["cid" => $channel->getCID()],
591+
['text' => ['$q' => 'cious']],
592+
["limit" => 1, "offset" => 0]
593+
);
594+
$this->assertSame(count($response['results']), 1);
588595
}
589596

590597
public function testGetMessage(){

0 commit comments

Comments
 (0)