We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit fcba540a authored by mattl's avatar mattl

Removed legacy OMB. Use OStatus for remote profiles.

parent e7a4ccb7
......@@ -131,8 +131,6 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
return;
}
common_broadcast_profile($profile);
$twitter_user = $this->twitterUserArray($profile, true);
if ($this->format == 'xml') {
......
......@@ -97,8 +97,6 @@ class ApiAccountUpdateProfileImageAction extends ApiAuthAction
$profile = $this->user->getProfile();
$profile->setOriginal($filename);
common_broadcast_profile($profile);
$twitter_user = $this->twitterUserArray($profile, true);
if ($this->format == 'xml') {
......
......@@ -386,7 +386,6 @@ class AvatarsettingsAction extends SettingsAction
$this->mode = 'upload';
// TRANS: Success message for having updated a user avatar.
$this->showForm(_('Avatar updated.'), true);
common_broadcast_profile($profile);
} else {
// TRANS: Error displayed on the avatar upload page if the avatar could not be updated for an unknown reason.
$this->showForm(_('Failed updating avatar.'));
......
......@@ -427,7 +427,6 @@ class ProfilesettingsAction extends SettingsAction
$user->query('COMMIT');
Event::handle('EndProfileSaveForm', array($this));
common_broadcast_profile($profile);
// TRANS: Confirmation shown when user profile settings are saved.
$this->showForm(_('Settings saved.'), true);
......
......@@ -35,8 +35,7 @@ if (!defined('STATUSNET')) {
/**
* Subscription action
*
* Subscribing to a profile. Does not work for OMB 0.1 remote subscriptions,
* but may work for other remote subscription protocols, like OStatus.
* Subscribing to a profile. Likely to work for OStatus profiles.
*
* Takes parameters:
*
......
......@@ -1376,7 +1376,7 @@ class Profile extends Managed_DataObject
$profile = null;
if (Event::handle('StartGetProfileFromURI', array($uri, &$profile))) {
// Get a local user or remote (OMB 0.1) profile
// Get a local user
$user = User::getKV('uri', $uri);
if (!empty($user)) {
$profile = $user->getProfile();
......
<?php
/*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, 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/>.
*/
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
/**
* Table Definition for remote_profile
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
class Remote_profile extends Managed_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
public $__table = 'remote_profile'; // table name
public $id; // int(4) primary_key not_null
public $uri; // varchar(255) unique_key
public $postnoticeurl; // varchar(255)
public $updateprofileurl; // varchar(255)
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
function hasRight($right)
{
$profile = Profile::getKV($this->id);
if ($profile) {
return $profile->hasright($right);
} else {
// TRANS: Exception thrown when a right for a non-existing user profile is checked.
throw new Exception(_("Missing profile."));
}
}
public static function schemaDef()
{
return array(
'description' => 'remote people (OMB)',
'fields' => array(
'id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'),
'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'),
'postnoticeurl' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL we use for posting notices'),
'updateprofileurl' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL we use for updates to this profile'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'unique keys' => array(
'remote_profile_uri_key' => array('uri'),
),
'foreign keys' => array(
'remote_profile_id_fkey' => array('profile', array('id' => 'id')),
),
);
}
}
......@@ -34,7 +34,6 @@ $classes = array('Schema_version',
'Avatar',
'Sms_carrier',
'User',
'Remote_profile',
'Subscription',
'Group_join_queue',
'Subscription_queue',
......
......@@ -770,12 +770,6 @@ class SubCommand extends Command
$target = $this->getProfile($this->other);
$remote = Remote_profile::getKV('id', $target->id);
if ($remote) {
// TRANS: Command exception text shown when trying to subscribe to an OMB profile using the subscribe command.
throw new CommandException(_("Can't subscribe to OMB profiles by command."));
}
try {
Subscription::start($this->user->getProfile(), $target);
// TRANS: Text shown after having subscribed to another user successfully.
......
......@@ -300,8 +300,6 @@ $default =
'location' =>
array('share' => 'user', // whether to share location; 'always', 'user', 'never'
'sharedefault' => false),
'omb' =>
array('timeout' => 5), // HTTP request timeout in seconds when contacting remote hosts for OMB updates
'logincommand' =>
array('disabled' => true),
'plugins' =>
......
......@@ -259,16 +259,12 @@ abstract class Installer
*/
function validateSiteProfile()
{
$fail = false;
$sprofile = $this->siteProfile;
if (empty($sprofile)) {
if (empty($this->siteProfile)) {
$this->updateStatus("No site profile selected.", true);
$fail = true;
return false;
}
return !$fail;
return true;
}
/**
......@@ -563,6 +559,8 @@ abstract class Installer
*/
function doInstall()
{
global $config;
$this->updateStatus("Initializing...");
ini_set('display_errors', 1);
error_reporting(E_ALL);
......@@ -572,9 +570,15 @@ abstract class Installer
if (!defined('STATUSNET')) {
define('STATUSNET', true);
}
require_once INSTALLDIR . '/lib/framework.php';
StatusNet::initDefaults($this->server, $this->path);
if ($this->siteProfile == "singleuser") {
// Until we use ['site']['profile']==='singleuser' everywhere
$config['singleuser']['enabled'] = true;
}
try {
$this->db = $this->setupDatabase();
if (!$this->db) {
......
......@@ -136,7 +136,6 @@ class Snapshot
$tables = array('user',
'notice',
'subscription',
'remote_profile',
'user_group');
foreach ($tables as $table) {
......
......@@ -1513,21 +1513,6 @@ function common_enqueue_notice($notice)
return true;
}
/**
* Legacy function to broadcast profile updates to OMB remote subscribers.
*
* XXX: This probably needs killing, but there are several bits of code
* that broadcast profile changes that need to be dealt with. AFAIK
* this function is only used for OMB. -z
*
* 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)
{
Event::handle('BroadcastProfile', array($profile));
}
function common_profile_url($nickname)
{
return common_local_url('showstream', array('nickname' => $nickname),
......
......@@ -633,7 +633,6 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
}
Event::handle('EndProfileSaveForm', array($this));
common_broadcast_profile($profile);
}
}
......
<?php
/**
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2011, StatusNet, Inc.
*
* OpenMicroBlogging plugin - add OpenMicroBloggin 0.1 support to
* StatusNet.
*
* Note: the OpenMicroBlogging protocol has been deprecated in favor of OStatus.
* This plugin is provided for backwards compatibility and experimentation.
*
* Please see the README and the OStatus plugin.
*
* PHP version 5
*
* 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/>.
*
* @category Sample
* @package StatusNet
* @author Zach Copley
* @copyright 2011 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/extlib/');
if (!defined('STATUSNET')) {
// This check helps protect against security problems;
// your code file can't be executed directly from the web.
exit(1);
}
/**
* OMB plugin main class
*
* Depends on: WebFinger plugin
*
* @category Integration
* @package StatusNet
* @author Zach Copley <zach@status.net>
* @copyright 2011 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
class OMBPlugin extends Plugin
{
/**
* Map URLs to actions
*
* @param Net_URL_Mapper $m path-to-action mapper
*
* @return boolean hook value; true means continue processing, false means stop.
*/
function onRouterInitialized($m)
{
$bare = array(
'requesttoken',
'accesstoken',
'userauthorization',
'postnotice',
'updateprofile',
'finishremotesubscribe'
);
foreach ($bare as $action) {
$m->connect(
'index.php?action=' . $action, array('action' => $action)
);
}
// exceptional
$m->connect('main/remote', array('action' => 'remotesubscribe'));
$m->connect(
'main/remote?nickname=:nickname',
array('action' => 'remotesubscribe'),
array('nickname' => '[A-Za-z0-9_-]+')
);
$m->connect(
'xrds',
array('action' => 'xrds', 'nickname' => $nickname)
);
return true;
}
/**
* Put saved notices into the queue for OMB distribution
*
* @param Notice $notice the notice to broadcast
* @param array $transports queuehandler's list of transports
* @return boolean true if queing was successful
*/
function onStartEnqueueNotice($notice, &$transports)
{
if ($notice->isLocal()) {
if ($notice->inScope(null)) {
array_unshift($transports, 'omb');
common_log(
LOG_INFO, "Notice {$notice->id} queued for OMB processing"
);
} else {
// Note: We don't do privacy-controlled OMB updates.
common_log(
LOG_NOTICE,
"Not queueing notice {$notice->id} for OMB because of "
. "privacy; scope = {$notice->scope}",
__FILE__
);
}
} else {
common_log(
LOG_NOTICE,
"Not queueing notice {$notice->id} for OMB because it's not "
. "local.",
__FILE__
);
}
return true;
}
/**
* Set up queue handlers for outgoing OMB pushes
*
* @param QueueManager $qm
* @return boolean hook return
*/
function onEndInitializeQueueManager(QueueManager $qm)
{
// Prepare outgoing distributions after notice save.
$qm->connect('omb', 'OmbQueueHandler');
$qm->connect('profile', 'ProfileQueueHandler');
return true;
}
/**
* Return OMB remote profile, if any
*
* @param Profile $profile
* @param string $uri
* @return boolen false if there's a remote profile
*/
function onStartGetProfileUri($profile, &$uri)
{
$remote = Remote_profile::getKV('id', $this->id);
if (!empty($remote)) {
$uri = $remote->uri;
return false;
}
return true;
}
/**
* We can't initiate subscriptions for a remote OMB profile; don't show
* subscribe button
*
* @param type $action
*/
function onStartShowProfileListSubscribeButton($action)
{
$remote = Remote_profile::getKV('id', $action->profile->id);
if (empty($remote)) {
false;
}
return true;
}
/**
* Check for illegal subscription attempts
*
* @param Profile $profile subscriber
* @param Profile $other subscribee
* @return hook return value
*/
function onStartSubscribe(Profile $profile, Profile $other)
{
// OMB 0.1 doesn't have a mechanism for local-server-
// originated subscription.
$omb01 = Remote_profile::getKV('id', $other->id);
if (!empty($omb01)) {
throw new ClientException(
// TRANS: Client error displayed trying to subscribe to an OMB 0.1 remote profile.
_m('You cannot subscribe to an OMB 0.1 '
. 'remote profile with this action.'
)
);
return false;
}
}
/**
* Throw an error if someone tries to tag a remote profile
*
* @param Profile $tagger_profile profile of the tagger
* @param Profile $tagged_profile profile of the taggee
* @param string $tag
*
* @return true
*/
function onStartTagProfile($tagger_profile, $tagged_profile, $tag)
{
// OMB 0.1 doesn't have a mechanism for local-server-
// originated tag.
$omb01 = Remote_profile::getKV('id', $tagged_profile->id);
if (!empty($omb01)) {
$this->clientError(
// TRANS: Client error displayed when trying to add an OMB 0.1 remote profile to a list.
_m('You cannot list an OMB 0.1 '
.'remote profile with this action.')
);
}
return false;
}
/**
* Check to make sure we're not tryng to untag an OMB profile
*
* // XXX: Should this ever happen?
*
* @param Profile_tag $ptag the profile tag
*/
function onUntagProfile($ptag)
{
// OMB 0.1 doesn't have a mechanism for local-server-
// originated tag.
$omb01 = Remote_profile::getKV('id', $ptag->tagged);
if (!empty($omb01)) {
$this->clientError(
// TRANS: Client error displayed when trying to (un)list an OMB 0.1 remote profile.
_m('You cannot (un)list an OMB 0.1 '
. 'remote profile with this action.')
);
return false;
}
}
/**
* Remove old OMB subscription tokens
*
* @param Profile $profile subscriber
* @param Profile $other subscribee
* @return hook return value
*/
function onEndUnsubscribe(Profile $profile, Profile $other)
{
$sub = Subscription::pkeyGet(
array('subscriber' => $profile->id, 'subscribed' => $other->id)
);
if (!empty($sub->token)) {
$token = new Token();
$token->tok = $sub->token;
if ($token->find(true)) {
$result = $token->delete();
if (!$result) {
common_log_db_error($token, 'DELETE', __FILE__);
throw new Exception(
// TRANS: Exception thrown when the OMB token for a subscription could not deleted on the server.
_m('Could not delete subscription OMB token.')
);
}
} else {
common_log(
LOG_ERR,
"Couldn't find credentials with token {$token->tok}",
__FILE__
);
}
}
return true;
}
/**
* Search for an OMB remote profile by URI
*
* @param string $uri remote profile URI
* @param Profile $profile the profile to set
* @return boolean hook value
*/
function onStartGetProfileFromURI($uri, &$profile)
{
$remote_profile = Remote_profile::getKV('uri', $uri);
if (!empty($remote_profile)) {
$profile = Profile::getKV('id', $remote_profile->profile_id);
return false;
}
return true;
}
/**
* Return OMB remote profiles as well as regular profiles
* in helper
*
* @param type $profile
* @param type $uri
*/
function onStartCommonProfileURI($profile, &$uri)
{
$remote = Remote_profile::getKV($profile->id);
if ($remote) {
$uri = $remote->uri;
return false;
}
return true;
}
/**
* Broadcast a profile over OMB
*
* @param Profile $profile to broadcast
* @return false
*/
function onBroadcastProfile($profile) {
$qm = QueueManager::get();
$qm->enqueue($profile, "profile");
return true;
}
function onStartProfileRemoteSubscribe($out, $profile)
{
$out->elementStart('li', 'entity_subscribe');
$url = common_local_url('remotesubscribe',
array('nickname' => $this->profile->nickname));
$out->element('a', array('href' => $url,