You are here

function messaging_xmpp_user_check in Messaging 6.3

Same name and namespace in other branches
  1. 6.4 messaging_xmpp/messaging_xmpp.module \messaging_xmpp_user_check()
  2. 6.2 messaging_xmpp/messaging_xmpp.module \messaging_xmpp_user_check()

Message user callback. Check user destination and availability

Parameters

$params: Array of parameters that can be overridden

  • method
  • queue
  • destination
  • log

and some others that cannot

  • account
  • message

Return value

array() $params with overridden values

See also

messaging_message_send_user()

1 string reference to 'messaging_xmpp_user_check'
messaging_xmpp_messaging in messaging_xmpp/messaging_xmpp.module
Implementation of hook_messaging

File

messaging_xmpp/messaging_xmpp.module, line 136
XMPP Messsaging. Messaging method plug-in

Code

function messaging_xmpp_user_check($message) {
  $account = $message->account;

  // If the option is 0 = Send anyway, we do nothing else
  if (!empty($account->uid) && ($what = messaging_user_setting('xmpp_offline', $account, 0))) {

    // Now we need to know whether the user is online, otherwise just return normal values
    if (!xmppframework_get_user_resources($account)) {

      // Now we need to decide
      if ($what == MESSAGING_XMPP_OFFLINE_QUEUE) {

        // Queue for when the user is online
        messaging_log('Queueing XMPP message for offline user', array(
          'uid' => $account->uid,
        ));
        $message->queue = TRUE;
      }
      elseif ($what == MESSAGING_XMPP_OFFLINE_DISCARD) {
        messaging_log('Discarding XMPP message for offline user', array(
          'uid' => $account->uid,
        ));

        // These two should cause the message to be discarded without logging
        $message->destination = FALSE;
        $message->log = FALSE;
      }
      elseif (messaging_method_info($what)) {
        messaging_log('Redirecting XMPP message for offline user', array(
          'uid' => $account->uid,
          'method' => $what,
        ));
        $message->method = $what;
      }
    }
  }
  return $params;
}