function messaging_xmpp_user_check in Messaging 6.4
Same name and namespace in other branches
- 6.2 messaging_xmpp/messaging_xmpp.module \messaging_xmpp_user_check()
- 6.3 messaging_xmpp/messaging_xmpp.module \messaging_xmpp_user_check()
Message user callback. Check user destination and availability
Parameters
$message: Message object. It can be redirected to other sending method.
See also
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 134 - XMPP Messsaging. Messaging method plug-in
Code
function messaging_xmpp_user_check($message) {
$account = $message
->get_user();
$message->process = FALSE;
// 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 = 1;
}
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->discard = TRUE;
$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;
$message->destination = FALSE;
// Keep on processing, the other method may have sth to say about this
$message->process = TRUE;
}
}
}
}