Skip to content

Commit d356220

Browse files
authored
Accept user id for reaction owner (#103)
1 parent 6755406 commit d356220

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

lib/GetStream/Stream/Client.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ public function getActivities($ids=null, $foreign_id_times=null, $enrich=false,
255255
}
256256
if (isset($reactions["own"]) && $reactions["own"]) {
257257
$query_params["withOwnReactions"] = true;
258+
if (isset($reactions["user_id"]) && $reactions["user_id"]) {
259+
$query_params["user_id"] = $reactions["user_id"];
260+
}
258261
$enrich = true;
259262
}
260263
if (isset($reactions["recent"]) && $reactions["recent"]) {

tests/integration/FeedTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,11 +847,18 @@ public function testGetActivities()
847847
$this->assertCount(2, $response["results"]);
848848
$this->assertCount(0, $response["results"][0]["reaction_counts"]);
849849

850-
$this->client->reactions()->add('like', $ids[0], "bob");
851-
$this->client->reactions()->add('comment', $ids[0], "bob");
850+
$this->client->reactions()->add('like', $ids[0], "bob1");
851+
$this->client->reactions()->add('comment', $ids[0], "bob2");
852852

853853
$response = $this->client->getActivities([$ids[0]], null, false, ['counts' => true, 'kinds' => ["like"]]);
854854
$this->assertCount(1, $response["results"]);
855855
$this->assertCount(1, $response["results"][0]["reaction_counts"]);
856+
857+
$response = $this->client->getActivities([$ids[0]], null, false, ['counts' => true, 'own' => true, "user_id" => 'bob1']);
858+
$this->assertCount(1, $response["results"]);
859+
$this->assertCount(2, $response["results"][0]["reaction_counts"]);
860+
$this->assertCount(1, $response["results"][0]["own_reactions"]);
861+
$this->assertCount(1, $response["results"][0]["own_reactions"]["like"]);
862+
$this->assertEquals("bob1", $response["results"][0]["own_reactions"]["like"][0]["user_id"]);
856863
}
857864
}

0 commit comments

Comments
 (0)