GitHost.io will be shut down on June 1, 2019. At that point this instance will be unreachable and all data will be irrevocably deleted. More details at https://about.gitlab.com/gitlab-hosted/#githost-is-shutting-down-on-june-1st-2019

Commit fcba540a authored by mmn's avatar mmn

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);
}
}
......
This diff is collapsed.
OMB (OpenMicroBlogging) plugin
==============================
This plugin encapsulates OpenMicroBlogging 0.1 functionality. OMB was the
original federation protocol for StatusNet, but has been deprecated
in favor of OStatus (see the OStatus plugin). This plugin is provided for
backward-compatibility with older sites, and for posterity.
External libraries
------------------
This is provided with the plugin, but you may wish to use a newer version of
the library, if and when it becomes available.
- libomb. a library for implementing OpenMicroBlogging 0.1
http://gitorious.org/libomb
Installation
------------
[TODO]
Offline Processing
------------------
Note: once you have a sizable number of users, sending OMB messages whenever
someone posts a message can really slow down your site; it may cause posting
to timeout. You may wish to enable queuing and handle OMB communication
offline. See the "queues and daemons" section of the main StatusNet README.
<?php
/**
* Access token class
*
* PHP version 5
*
* @category Action
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Robin Millette <millette@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008-2011, 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);
}
require_once dirname(__FILE__) . '/../extlib/libomb/service_provider.php';
require_once dirname(__FILE__) . '/../lib/omb.php';
/**
* Access token class
*
* @category Action
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Robin Millette <millette@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
class AccesstokenAction extends Action
{
/**
* Class handler
*
* @param array $args query arguments
*
* @return nothing
*
**/
function handle($args)
{
parent::handle($args);
try {
$srv = new OMB_Service_Provider(null, omb_oauth_datastore(),
omb_oauth_server());
$srv->writeAccessToken();
} catch (Exception $e) {
$this->serverError($e->getMessage());
}
}
}
<?php
/**
* Handler for remote subscription finish callback
*
* PHP version 5
*
* @category Action
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Robin Millette <millette@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008-2011, 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); }
require_once dirname(__FILE__) . '/../extlib/libomb/service_consumer.php';
require_once dirname(__FILE__) . '/../lib/omb.php';
/**
* Handler for remote subscription finish callback
*
* When a remote user subscribes a local user, a redirect to this action is
* issued after the remote user authorized their service to subscribe.
*
* @category Action
* @package Laconica
* @author Evan Prodromou <evan@status.net>
* @author Robin Millette <millette@controlyourself.ca>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://laconi.ca/
*/
class FinishremotesubscribeAction extends Action
{
/**
* Class handler.
*
* @param array $args query arguments
*
* @return nothing
*
*/
function handle($args)
{
parent::handle($args);
/* Restore session data. RemotesubscribeAction should have stored
this entry. */
$service = unserialize($_SESSION['oauth_authorization_request']);
if (!$service) {
// TRANS: Client error displayed when subscribing to a remote profile and an unexpected response is received.
$this->clientError(_('Not expecting this response!'));
return;
}
common_debug('stored request: '. print_r($service, true), __FILE__);
/* Create user objects for both users. Do it early for request
validation. */
$user = User::getKV('uri', $service->getListeneeURI());
if (!$user) {
// TRANS: Client error displayed when subscribing to a remote profile that does not exist.
$this->clientError(_('User being listened to does not exist.'));
return;
}
$other = User::getKV('uri', $service->getListenerURI());
if ($other) {
// TRANS: Client error displayed when subscribing to a remote profile that is a local profile.
$this->clientError(_('You can use the local subscription!'));
return;
}
$remote = Remote_profile::getKV('uri', $service->getListenerURI());
if ($remote) {
// Note remote profile may not have been saved yet.
// @fixme not convinced this is correct at all!
$profile = Profile::getKV($remote->id);
if ($user->hasBlocked($profile)) {
// TRANS: Client error displayed when subscribing to a remote profile that is blocked form subscribing to.
$this->clientError(_('That user has blocked you from subscribing.'));
return;
}
}
/* Perform the handling itself via libomb. */
try {
$service->finishAuthorization();
} catch (OAuthException $e) {
if ($e->getMessage() == 'The authorized token does not equal the ' .
'submitted token.') {
// TRANS: Client error displayed when subscribing to a remote profile without providing an authorised token.
$this->clientError(_('You are not authorized.'));
return;
} else {
// TRANS: Client error displayed when subscribing to a remote profile and conversion of the request token to access token fails.
$this->clientError(_('Could not convert request token to ' .
'access token.'));
return;
}
} catch (OMB_RemoteServiceException $e) {
// TRANS: Client error displayed when subscribing to a remote profile fails because of an unsupported version of the OMB protocol.
$this->clientError(_('Remote service uses unknown version of ' .
'OMB protocol.'));
return;
} catch (Exception $e) {
common_debug('Got exception ' . print_r($e, true), __FILE__);
$this->clientError($e->getMessage());
return;
}
/* The service URLs are not accessible from datastore, so setting them
after insertion of the profile. */
$remote = Remote_profile::getKV('uri', $service->getListenerURI());
$orig_remote = clone($remote);
$remote->postnoticeurl =
$service->getServiceURI(OMB_ENDPOINT_POSTNOTICE);
$remote->updateprofileurl =
$service->getServiceURI(OMB_ENDPOINT_UPDATEPROFILE);
if (!$remote->update($orig_remote)) {
// TRANS: Server error displayed when subscribing to a remote profile fails because the remote profile could not be updated.
$this->serverError(_('Error updating remote profile.'));
return;
}
/* Clear the session data. */
unset($_SESSION['oauth_authorization_request']);
/* If we show subscriptions in reverse chronological order, the new one
should show up close to the top of the page. */
common_redirect(common_local_url('subscribers', array('nickname' =>
$user->nickname)),
303);
}
}
<?php
/**
* Handle postnotice action
*
* PHP version 5
*
* @category Action
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Robin Millette <millette@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008-2011, 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); }
require_once dirname(__FILE__) . '/../lib/omb.php';
require_once dirname(__FILE__) . '/../extlib/libomb/service_provider.php';
/**
* Handler for postnotice action
*
* @category Action
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Robin Millette <millette@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
class PostnoticeAction extends Action
{
/**
* For initializing members of the class.
*
* @param array $argarray misc. arguments
*
* @return boolean true
*/
function prepare($argarray)
{
StatusNet::setApi(true); // Send smaller error pages
parent::prepare($argarray);
try {
$this->checkNotice();
} catch (Exception $e) {
$this->clientError($e->getMessage());
return false;
}
return true;
}
function handle($args)
{
parent::handle($args);
try {
$srv = new OMB_Service_Provider(null, omb_oauth_datastore(),
omb_oauth_server());
$srv->handlePostNotice();
} catch (OMB_RemoteServiceException $rse) {
$msg = $rse->getMessage();
if (preg_match('/Revoked accesstoken/', $msg) ||
preg_match('/No subscriber/', $msg)) {
$this->clientError($msg, 403);
} else {
$this->clientError($msg);
}
} catch (Exception $e) {
$this->serverError($e->getMessage());
return;
}
}
function checkNotice()
{
$content = common_shorten_links($_POST['omb_notice_content']);
if (Notice::contentTooLong($content)) {
// TRANS: Client error displayed if the notice posted has too many characters.
$this->clientError(_('Invalid notice content.'), 400);
return false;
}
$license = $_POST['omb_notice_license'];
$site_license = common_config('license', 'url');
if ($license && !common_compatible_license($license, $site_license)) {
// TRANS: Exception thrown if a notice's license is not compatible with the StatusNet site license.
// TRANS: %1$s is the notice license, %2$s is the StatusNet site's license.
throw new Exception(sprintf(_('Notice license "%1$s" is not ' .
'compatible with site license "%2$s".'),
$license, $site_license));
}
}
}
<?php
/**
* Handler for remote subscription
*
* PHP version 5
*
* @category Action
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Robin Millette <millette@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008-2011 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); }
require_once dirname(__FILE__) . '/../lib/omb.php';
require_once dirname(__FILE__) . '/../extlib/libomb/service_consumer.php';
require_once dirname(__FILE__) . '/../extlib/libomb/profile.php';
/**
* Handler for remote subscription
*
* @category Action
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Robin Millette <millette@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
class RemotesubscribeAction extends Action
{
var $nickname;
var $profile_url;
var $err;
function prepare($args)
{
parent::prepare($args);
if (common_logged_in()) {
// TRANS: Client error displayed when using remote subscribe for a local entity.
$this->clientError(_('You can use the local subscription!'));
return false;
}
$this->nickname = $this->trimmed('nickname');
$this->profile_url = $this->trimmed('profile_url');
return true;
}
function handle($args)
{
parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
/* Use a session token for CSRF protection. */
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->showForm(_('There was a problem with your session token. '.
'Try again, please.'));
return;
}
$this->remoteSubscription();
} else {
$this->showForm();
}
}
function showForm($err=null)
{
$this->err = $err;
$this->showPage();