normalize jids before comparison
darcs-hash:20080623041816-34904-9a55d96a3e76e27b399706f7247bb715f396366b.gz
This commit is contained in:
parent
8b89e1cfb0
commit
e4f5893f73
@ -51,6 +51,14 @@ class XMPPDaemon {
|
|||||||
return !$this->conn->disconnected;
|
return !$this->conn->disconnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalize_jid($jid) {
|
||||||
|
preg_match("/(?:([^\@]+)\@)?([^\/]+)(?:\/(.*))?$/", $jid, $matches);
|
||||||
|
$node = $matches[1];
|
||||||
|
$server = $matches[2];
|
||||||
|
$resource = $matches[3];
|
||||||
|
return strtolower($node.'@'.$server);
|
||||||
|
}
|
||||||
|
|
||||||
function handle() {
|
function handle() {
|
||||||
while(!$this->conn->disconnected) {
|
while(!$this->conn->disconnected) {
|
||||||
$payloads = $this->conn->processUntil(array('message', 'presence',
|
$payloads = $this->conn->processUntil(array('message', 'presence',
|
||||||
@ -73,9 +81,10 @@ class XMPPDaemon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handle_message(&$pl) {
|
function handle_message(&$pl) {
|
||||||
$user = User::staticGet('jabber', $pl['from']);
|
$from = $this->normalize_jid($pl['from']);
|
||||||
|
$user = User::staticGet('jabber', $from);
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->log(LOG_WARNING, 'Message from unknown user ' . $pl['from']);
|
$this->log(LOG_WARNING, 'Message from unknown user ' . $from);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($this->handle_command($user, $pl['body'])) {
|
if ($this->handle_command($user, $pl['body'])) {
|
||||||
@ -147,9 +156,10 @@ class XMPPDaemon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handle_presence(&$pl) {
|
function handle_presence(&$pl) {
|
||||||
$user = User::staticGet('jabber', $pl['from']);
|
$from = $this->normalize_jid($pl['from']);
|
||||||
|
$user = User::staticGet('jabber', $from);
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->log(LOG_WARNING, 'Message from unknown user ' . $pl['from']);
|
$this->log(LOG_WARNING, 'Message from unknown user ' . $from);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($user->updatefrompresence) {
|
if ($user->updatefrompresence) {
|
||||||
|
Loading…
Reference in New Issue
Block a user