You are here

function nodejs_get_content_channel_users in Node.js integration 8

Same name and namespace in other branches
  1. 7 nodejs.module \nodejs_get_content_channel_users()

Get a list of users in a content channel.

Parameters

mixed $channel:

File

./nodejs.module, line 76

Code

function nodejs_get_content_channel_users($channel) {
  $message = (object) array(
    'channel' => $channel,
  );

  // Http request went ok, process Node.js server response.
  if ($node_response = nodejs_get_nodejs()
    ->getContentTokenUsers($message)) {
    if (isset($node_response->error)) {
      \Drupal::logger('nodejs')
        ->error(t('Error getting content channel users for channel "%channel" on the Node.js server. Server response: %error', array(
        '%channel' => $channel,
        '%error' => $node_response->error,
      )));
      return FALSE;
    }
    else {
      return array(
        'uids' => !empty($node_response->users->uids) ? $node_response->users->uids : array(),
        'authTokens' => !empty($node_response->users->authTokens) ? $node_response->users->authTokens : array(),
      );
    }
  }
  else {
    return FALSE;
  }
}