public function __get($name) { $property = Utils::snakeCase($name); if (property_exists($this, $property) && $name !== '_type') { return $this->{$property}; } else { throw new \Exception("Undefined or inaccessible property {$property}"); } }
public function addToken($token) { if (empty($token)) { return; } $interactor = new MultiCurlInteractor(); $interactor->setResponseFactory(new SlackResponseFactory()); $tempCommander = new CustomCommander($token, $interactor); $auth = $tempCommander->execute('auth.test')->getBody(); if (Utils::getWorkflows()->setPassword('token.' . $auth['team_id'], $token)) { $this->addTeam($auth); // If safe password is set, remove the unsafe one Utils::getWorkflows()->delete('token.' . $auth['team_id']); $this->services[$auth['team_id']] = new SingleTeamSlackService($auth['team_id']); } }
public function __construct() { $this->workflows = Utils::getWorkflows(); $this->results = []; }
public function openFileAction($file) { Utils::openUrl($file->getPermalink()); }
private function getUsers($excludeSlackBot = false) { $users = $this->service->getUsers(true); if ($excludeSlackBot !== false) { $users = Utils::filter($users, function ($user) { return $user->getId() !== $user->getAuth()->user_id; }); } else { $meInTeams = Utils::filter($users, function ($user) { return $user->getId() === $user->getAuth()->user_id; }); foreach ($meInTeams as $me) { $me->setName('slackbot'); $me->getProfile()->real_name = 'slackbot'; } } return $users; }
public function refreshCache() { // Refresh auth Utils::getWorkflows()->delete('auth.' . $this->teamId); $teamName = $this->getAuth()->team; Utils::log("Auth refreshed for team {$teamName}"); // Refresh channels Utils::getWorkflows()->delete('channels.' . $this->teamId); $this->getChannels(); Utils::log("Channels refreshed for team {$teamName}"); // Refresh groups Utils::getWorkflows()->delete('groups.' . $this->teamId); $this->getGroups(); Utils::log("Groups refreshed for team {$teamName}"); // Refresh user icons foreach ($this->getUsers() as $user) { Utils::getWorkflows()->delete('user.image.' . $user->getId()); } // Refresh users Utils::getWorkflows()->delete('users.' . $this->teamId); $users = $this->getUsers(); Utils::log("Users refreshed for team {$teamName}"); foreach ($users as $user) { $this->getProfileIcon($user->getId()); } Utils::log("Profile icons refreshed for team {$teamName}"); // Refresh file icons foreach ($this->getFiles() as $file) { Utils::getWorkflows()->delete('file.image.' . $file->getId()); $this->getFileIcon($file->getId()); } Utils::log("File icons refreshed for team {$teamName}"); // Refresh ims Utils::getWorkflows()->delete('ims.' . $this->teamId); $this->getIms(); Utils::log("Ims refreshed for team {$teamName}"); }