summaryrefslogtreecommitdiff
path: root/xmppdaemon.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlezvous.ca>2008-06-26 14:11:44 -0400
committerEvan Prodromou <evan@controlezvous.ca>2008-06-26 14:11:44 -0400
commitdb2d79cd31f6cdf4d7f45b2ef610f3fb40df564d (patch)
tree577a36079a5763a9c66095d358ec478173b84b02 /xmppdaemon.php
parentb7d927cd41bca85d55a45f450bbbf87f61bced24 (diff)
some UI changes to the IM settings
darcs-hash:20080626181144-34904-87503e70e6705b06ebb6c19910583f4fba1b22e0.gz
Diffstat (limited to 'xmppdaemon.php')
-rwxr-xr-xxmppdaemon.php43
1 files changed, 40 insertions, 3 deletions
diff --git a/xmppdaemon.php b/xmppdaemon.php
index 1a77c4340..3f2b575e4 100755
--- a/xmppdaemon.php
+++ b/xmppdaemon.php
@@ -88,6 +88,22 @@ class XMPPDaemon {
}
}
+ 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;
@@ -95,8 +111,6 @@ class XMPPDaemon {
if (strlen($pl['body']) == 0) {
return;
}
- $from = jabber_normalize_jid($pl['from']);
- $user = User::staticGet('jabber', $from);
if (!$user) {
$this->log(LOG_WARNING, 'Message from unknown user ' . $from);
return;
@@ -180,8 +194,31 @@ class XMPPDaemon {
'Accepted subscription from ' . $from);
break;
case 'subscribed':
- case 'unsubscribe':
+ $confirm = $this->get_confirmation($from);
+ if ($confirm) {
+ $user = User::staticGet($confirm->user_id);
+ if ($user) {
+ jabber_confirm_address($confirm->code,
+ $user->nickname,
+ $confirm->address);
+ } else {
+ $this->log(LOG_WARNING,
+ 'got unexpected subscribed message from ' . $from);
+ }
+ }
case 'unsubscribed':
+ $user = $this->get_user($from);
+ if ($user) {
+ $this->set_notify($user, false);
+ }
+
+ $confirm = $this->get_confirmation($from);
+ if ($confirm) {
+ $user = User::staticGet($confirm->user_id);
+ if ($user) {
+ }
+ }
+ case 'unsubscribe':
$this->log(LOG_INFO,
'Ignoring "' . $pl['type'] . '" from ' . $from);
break;