diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/activity.php | 3 | ||||
| -rw-r--r-- | lib/profilequeuehandler.php | 48 | ||||
| -rw-r--r-- | lib/queuemanager.php | 3 | ||||
| -rw-r--r-- | lib/util.php | 14 | 
4 files changed, 63 insertions, 5 deletions
| diff --git a/lib/activity.php b/lib/activity.php index fa4ae0274..33932ad0e 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -691,6 +691,9 @@ class ActivityVerb      const UNFAVORITE = 'http://ostatus.org/schema/1.0/unfavorite';      const UNFOLLOW   = 'http://ostatus.org/schema/1.0/unfollow';      const LEAVE      = 'http://ostatus.org/schema/1.0/leave'; + +    // For simple profile-update pings; no content to share. +    const UPDATE_PROFILE = 'http://ostatus.org/schema/1.0/update-profile';  }  class ActivityContext diff --git a/lib/profilequeuehandler.php b/lib/profilequeuehandler.php new file mode 100644 index 000000000..e8a00aef3 --- /dev/null +++ b/lib/profilequeuehandler.php @@ -0,0 +1,48 @@ +<?php +/* + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2010, StatusNet, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program.  If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * @package QueueHandler + * @maintainer Brion Vibber <brion@status.net> + */ + +class ProfileQueueHandler extends QueueHandler +{ + +    function transport() +    { +        return 'profile'; +    } + +    function handle($profile) +    { +        if (!($profile instanceof Profile)) { +            common_log(LOG_ERR, "Got a bogus profile, not broadcasting"); +            return true; +        } + +        if (Event::handle('StartBroadcastProfile', array($profile))) { +            require_once(INSTALLDIR.'/lib/omb.php'); +            omb_broadcast_profile($profile); +        } +        Event::handle('EndBroadcastProfile', array($profile)); +        return true; +    } + +} diff --git a/lib/queuemanager.php b/lib/queuemanager.php index 8f8c8f133..9fdc80110 100644 --- a/lib/queuemanager.php +++ b/lib/queuemanager.php @@ -262,6 +262,9 @@ abstract class QueueManager extends IoManager                  $this->connect('sms', 'SmsQueueHandler');              } +            // Broadcasting profile updates to OMB remote subscribers +            $this->connect('profile', 'ProfileQueueHandler'); +              // XMPP output handlers...              if (common_config('xmpp', 'enabled')) {                  // Delivery prep, read by queuedaemon.php: diff --git a/lib/util.php b/lib/util.php index 7fb2c6c4b..9354431f2 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1119,12 +1119,16 @@ function common_enqueue_notice($notice)      return true;  } -function common_broadcast_profile($profile) +/** + * Broadcast profile updates to OMB and other remote subscribers. + * + * Since this may be slow with a lot of subscribers or bad remote sites, + * this is run through the background queues if possible. + */ +function common_broadcast_profile(Profile $profile)  { -    // XXX: optionally use a queue system like http://code.google.com/p/microapps/wiki/NQDQ -    require_once(INSTALLDIR.'/lib/omb.php'); -    omb_broadcast_profile($profile); -    // XXX: Other broadcasts...? +    $qm = QueueManager::get(); +    $qm->enqueue($profile, "profile");      return true;  } | 
