You are here

private function User::getFromList in Rocket.Chat 8.2

2 calls to User::getFromList()
User::getUserProxy in modules/rocket_chat_api/src/RocketChat/Element/User.php
Retrieve the Proxy, create the User if needed.
User::isInList in modules/rocket_chat_api/src/RocketChat/Element/User.php
Check if this Channel is in the List provided.

File

modules/rocket_chat_api/src/RocketChat/Element/User.php, line 110

Class

User

Namespace

Drupal\rocket_chat_api\RocketChat\Element

Code

private function getFromList($list) {
  foreach ($list as $user) {
    $found = false;
    if (!empty($this->username) && $user["username"] == $this->username) {
      $found = TRUE;
    }
    if (!empty($this->email)) {
      if (isset($user['emails'])) {
        foreach ($user['emails'] as $email) {
          if ($email['address'] == $this->email) {
            $found = TRUE;
            return $user;
          }
        }
      }
      else {
        if (!(strcmp($user['type'], "bot") === 0)) {
          $this->Logger
            ->warning("User is missing the email property |" . json_encode($user, JSON_PRETTY_PRINT));
        }
      }
    }
    if ($found) {
      return $user;
    }
  }
  return NULL;
}