Skip to content
This repository has been archived by the owner on Jun 4, 2018. It is now read-only.

Commit

Permalink
Fix authed user identification
Browse files Browse the repository at this point in the history
  • Loading branch information
sagebind committed Dec 15, 2015
1 parent e0d4615 commit 20059bd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/RealTimeClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public function connect()
// get the team info
$this->team = new Team($this, $responseData['team']);

// Populate self user.
$this->users[$responseData['self']['id']] = new User($this, $responseData['self']);

// populate list of users
foreach ($responseData['users'] as $data) {
$this->users[$data['id']] = new User($this, $data);
Expand Down Expand Up @@ -167,6 +170,10 @@ public function getChannels()
*/
public function getChannelById($id)
{
if (!isset($this->channels[$id])) {
return Promise\reject(new ApiException("No channel exists for ID '$id'."));
}

return Promise\resolve($this->channels[$id]);
}

Expand All @@ -183,6 +190,10 @@ public function getGroups()
*/
public function getGroupById($id)
{
if (!isset($this->groups[$id])) {
return Promise\reject(new ApiException("No group exists for ID '$id'."));
}

return Promise\resolve($this->groups[$id]);
}

Expand All @@ -199,6 +210,10 @@ public function getDMs()
*/
public function getDMById($id)
{
if (!isset($this->dms[$id])) {
return Promise\reject(new ApiException("No DM exists for ID '$id'."));
}

return Promise\resolve($this->dms[$id]);
}

Expand All @@ -215,6 +230,10 @@ public function getUsers()
*/
public function getUserById($id)
{
if (!isset($this->users[$id])) {
return Promise\reject(new ApiException("No user exists for ID '$id'."));
}

return Promise\resolve($this->users[$id]);
}

Expand Down

0 comments on commit 20059bd

Please sign in to comment.