Skip to content

Commit bbd4cc5

Browse files
authored
Add kinds filter to reaction params (#94)
* fix version passed in header
1 parent aa28430 commit bbd4cc5

5 files changed

Lines changed: 26 additions & 13 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
/composer.lock
1+
composer.lock
22
/vendor
33
/build
4+
.phpunit.result.cache

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
stream-php
2-
==========
1+
# stream-php
32

43
[![Build Status](https://travis-ci.org/GetStream/stream-php.svg?branch=master)](https://travis-ci.org/GetStream/stream-php)
54
[![Coverage Status](https://coveralls.io/repos/github/GetStream/stream-php/badge.svg?branch=master)](https://coveralls.io/github/GetStream/stream-php?branch=master)
@@ -33,7 +32,7 @@ composer require get-stream/stream:"~2.1.0"
3332

3433
See the [Travis configuration](.travis.yml) for details of how it is built and tested against different PHP versions.
3534

36-
### Documentatation
35+
### Documentation
3736

3837
Our full documentation for this package is available at [https://getstream.io/docs/php/](https://getstream.io/docs/php/).
3938

@@ -167,7 +166,7 @@ $batcher->followMany($follows);
167166
Generating tokens for client-side usage:
168167

169168
```php
170-
// Generating a user token
169+
// Generating a user token
171170
$userToken = $client->createUserSessionToken("the-user-id");
172171
```
173172

@@ -223,7 +222,6 @@ The users module has the following methods.
223222

224223
Also see documention on the [users endpoint](https://getstream.io/docs/php/#users_introduction)
225224

226-
227225
```php
228226

229227
$user = $client->users()->add('42');

lib/GetStream/Stream/BaseFeed.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ public function getActivities($offset = 0, $limit = 20, $options = [], $enrich=f
233233
$query_params["withReactionCounts"] = true;
234234
$enrich = true;
235235
}
236+
if(isset($reactions["kinds"]) && $reactions["kinds"]){
237+
$query_params["reactionKindsFilter"] = implode(",", $reactions["kinds"]);
238+
$enrich = true;
239+
}
236240
}
237241

238242
$prefix_enrich = $enrich ? 'enrich/' : '';

lib/GetStream/Stream/Client.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use DateTime;
55
use Exception;
66

7-
const VERSION = '2.6.0';
7+
const VERSION = '4.0.1';
88

99
class Client implements ClientInterface
1010
{
@@ -268,6 +268,10 @@ public function getActivities($ids=null, $foreign_id_times=null, $enrich=false,
268268
$query_params["withReactionCounts"] = true;
269269
$enrich = true;
270270
}
271+
if(isset($reactions["kinds"]) && $reactions["kinds"]){
272+
$query_params["reactionKindsFilter"] = implode(",", $reactions["kinds"]);
273+
$enrich = true;
274+
}
271275
}
272276

273277
$token = $this->signer->jwtScopeToken('*', 'activities', '*');
@@ -339,5 +343,4 @@ public function createRedirectUrl($targetUrl, $events)
339343
$analytics = new Analytics($this, $this->api_key, $token);
340344
return $analytics->createRedirectUrl($targetUrl, $events);
341345
}
342-
343346
}

tests/integration/FeedTest.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,8 @@ public function testVerifyOff()
534534
$this->user1->setGuzzleDefaultOption('verify', true);
535535
$activities_after = $this->user1->getActivities(0, 2);
536536
$this->assertSame(
537-
$activities_before['results'][0]['id'],
538-
$activities_after['results'][0]['id'],
537+
$activities_before['results'],
538+
$activities_after['results'],
539539
);
540540
}
541541

@@ -843,8 +843,15 @@ public function testGetActivities(){
843843
$this->assertCount(2, $response);
844844
$this->assertEquals(sort($activities), sort($response), $canonicalize=true);
845845

846-
$response = $this->client->getActivities($ids, null, false, array('withReactionCounts' => true));
847-
$this->assertCount(2,$response);
848-
$this->assertEquals($response["results"][0]["reaction_counts"], 0);
846+
$response = $this->client->getActivities($ids, null, false, ['counts' => true]);
847+
$this->assertCount(2, $response["results"]);
848+
$this->assertCount(0, $response["results"][0]["reaction_counts"]);
849+
850+
$this->client->reactions()->add('like', $ids[0], "bob");
851+
$this->client->reactions()->add('comment', $ids[0], "bob");
852+
853+
$response = $this->client->getActivities([$ids[0]], null, false, ['counts' => true, 'kinds' => ["like"]]);
854+
$this->assertCount(1, $response["results"]);
855+
$this->assertCount(1, $response["results"][0]["reaction_counts"]);
849856
}
850857
}

0 commit comments

Comments
 (0)