}
}
+ function get_user($from) {
+ $user = User::staticGet('jabber', jabber_normalize_jid($from));
+ return $user;
+ }
+
+ function get_confirmation($from) {
+ $confirm = new Confirm_address();
+ $confirm->address = $from;
+ $confirm->address_type = 'jabber';
+ if ($confirm->find(TRUE)) {
+ return $confirm;
+ } else {
+ return NULL;
+ }
+ }
+
function handle_message(&$pl) {
if ($pl['type'] != 'chat') {
return;
if (strlen($pl['body']) == 0) {
return;
}
+
$from = jabber_normalize_jid($pl['from']);
- $user = User::staticGet('jabber', $from);
+ $user = $this->get_user($from);
+
if (!$user) {
$this->log(LOG_WARNING, 'Message from unknown user ' . $from);
return;
'Accepted subscription from ' . $from);
break;
case 'subscribed':
- case 'unsubscribe':
case 'unsubscribed':
+ case 'unsubscribe':
$this->log(LOG_INFO,
'Ignoring "' . $pl['type'] . '" from ' . $from);
break;