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']);
     }
 }
Esempio n. 2
0
 public function __construct()
 {
     $this->workflows = Utils::getWorkflows();
     $this->results = [];
 }
 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}");
 }