Fixed uniqueness

This commit is contained in:
Alex Renoki 2020-09-17 11:30:36 +03:00
parent b7ba98a6a6
commit 16ff2aa2b6
3 changed files with 37 additions and 2 deletions

View File

@ -323,7 +323,7 @@ class LocalChannelManager implements ChannelManager
$members = collect($members)->map(function ($user) {
return json_decode($user);
})->unique('id')->toArray();
})->unique('user_id')->toArray();
return new FulfilledPromise($members);
}

View File

@ -350,7 +350,7 @@ class RedisChannelManager extends LocalChannelManager
->map(function ($user) {
return json_decode($user);
})
->unique('id')
->unique('user_id')
->toArray();
});
}

View File

@ -73,6 +73,41 @@ class PresenceChannelTest extends TestCase
]);
}
$rick->assertSentEvent('pusher_internal:subscription_succeeded', [
'channel' => 'presence-channel',
'data' => json_encode([
'presence' => [
'ids' => ['1'],
'hash' => ['1' => []],
'count' => 1,
],
]),
]);
$morty->assertSentEvent('pusher_internal:subscription_succeeded', [
'channel' => 'presence-channel',
'data' => json_encode([
'presence' => [
'ids' => ['1', '2'],
'hash' => ['1' => [], '2' => []],
'count' => 2,
],
]),
]);
// The duplicated-user_id connection should get basically the list of ids
// without dealing with duplicate user ids.
$pickleRick->assertSentEvent('pusher_internal:subscription_succeeded', [
'channel' => 'presence-channel',
'data' => json_encode([
'presence' => [
'ids' => ['1', '2'],
'hash' => ['1' => [], '2' => []],
'count' => 2,
],
]),
]);
$this->channelManager
->getGlobalConnectionsCount('1234', 'presence-channel')
->then(function ($total) {