summaryrefslogtreecommitdiff
path: root/plugins/OStatus
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-03-02 07:33:18 +0000
committerZach Copley <zach@status.net>2010-03-02 07:33:18 +0000
commit6c1321b108206d05b75703da22ea8abab82071bf (patch)
tree7380e7eb3f0ab121ea25413ddf6f847c8915fc2c /plugins/OStatus
parentdbb9957eea1887265532dbae000fb1fc30005988 (diff)
parent40e1b249cf1535a6074c8b32e5820c8ad6427836 (diff)
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
Diffstat (limited to 'plugins/OStatus')
-rw-r--r--plugins/OStatus/OStatusPlugin.php57
-rw-r--r--plugins/OStatus/actions/ostatussub.php6
-rw-r--r--plugins/OStatus/actions/pushhub.php2
-rw-r--r--plugins/OStatus/classes/HubSub.php8
-rw-r--r--plugins/OStatus/classes/Magicsig.php4
-rw-r--r--plugins/OStatus/classes/Ostatus_profile.php4
-rw-r--r--plugins/OStatus/lib/discovery.php2
-rw-r--r--plugins/OStatus/lib/xrd.php21
-rw-r--r--plugins/OStatus/locale/OStatus.po280
-rw-r--r--plugins/OStatus/scripts/updateostatus.php127
10 files changed, 448 insertions, 63 deletions
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index 720dedd0a..4ffbba45b 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -222,31 +222,62 @@ class OStatusPlugin extends Plugin
}
/**
- *
+ * Find any explicit remote mentions. Accepted forms:
+ * Webfinger: @user@example.com
+ * Profile link: @example.com/mublog/user
+ * @param Profile $sender (os user?)
+ * @param string $text input markup text
+ * @param array &$mention in/out param: set of found mentions
+ * @return boolean hook return value
*/
function onEndFindMentions($sender, $text, &$mentions)
{
- preg_match_all('/(?:^|\s+)@((?:\w+\.)*\w+@(?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+)/',
+ preg_match_all('!(?:^|\s+)
+ @( # Webfinger:
+ (?:\w+\.)*\w+ # user
+ @ # @
+ (?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+ # domain
+ | # Profile:
+ (?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+ # domain
+ (?:/\w+)+ # /path1(/path2...)
+ )!x',
$text,
$wmatches,
PREG_OFFSET_CAPTURE);
foreach ($wmatches[1] as $wmatch) {
-
- $webfinger = $wmatch[0];
-
- $this->log(LOG_INFO, "Checking Webfinger for address '$webfinger'");
-
- $oprofile = Ostatus_profile::ensureWebfinger($webfinger);
+ $target = $wmatch[0];
+ $oprofile = null;
+
+ if (strpos($target, '/') === false) {
+ $this->log(LOG_INFO, "Checking Webfinger for address '$target'");
+ try {
+ $oprofile = Ostatus_profile::ensureWebfinger($target);
+ } catch (Exception $e) {
+ $this->log(LOG_ERR, "Webfinger check failed: " . $e->getMessage());
+ }
+ } else {
+ $schemes = array('https', 'http');
+ foreach ($schemes as $scheme) {
+ $url = "$scheme://$target";
+ $this->log(LOG_INFO, "Checking profile address '$url'");
+ try {
+ $oprofile = Ostatus_profile::ensureProfile($url);
+ if ($oprofile) {
+ continue;
+ }
+ } catch (Exception $e) {
+ $this->log(LOG_ERR, "Profile check failed: " . $e->getMessage());
+ }
+ }
+ }
if (empty($oprofile)) {
-
- $this->log(LOG_INFO, "No Ostatus_profile found for address '$webfinger'");
-
+ $this->log(LOG_INFO, "No Ostatus_profile found for address '$target'");
} else {
- $this->log(LOG_INFO, "Ostatus_profile found for address '$webfinger'");
+ $this->log(LOG_INFO, "Ostatus_profile found for address '$target'");
if ($oprofile->isGroup()) {
continue;
@@ -261,7 +292,7 @@ class OStatusPlugin extends Plugin
}
}
$mentions[] = array('mentioned' => array($profile),
- 'text' => $wmatch[0],
+ 'text' => $target,
'position' => $pos,
'url' => $profile->profileurl);
}
diff --git a/plugins/OStatus/actions/ostatussub.php b/plugins/OStatus/actions/ostatussub.php
index aae22f868..f45e6a8d1 100644
--- a/plugins/OStatus/actions/ostatussub.php
+++ b/plugins/OStatus/actions/ostatussub.php
@@ -332,6 +332,7 @@ class OStatusSubAction extends Action
if ($this->oprofile->isGroup()) {
$group = $this->oprofile->localGroup();
if ($user->isMember($group)) {
+ // TRANS: OStatus remote group subscription dialog error.
$this->showForm(_m('Already a member!'));
return;
}
@@ -341,18 +342,22 @@ class OStatusSubAction extends Action
Event::handle('EndJoinGroup', array($group, $user));
$this->successGroup();
} else {
+ // TRANS: OStatus remote group subscription dialog error.
$this->showForm(_m('Remote group join failed!'));
}
} else {
+ // TRANS: OStatus remote group subscription dialog error.
$this->showForm(_m('Remote group join aborted!'));
}
} else {
$local = $this->oprofile->localProfile();
if ($user->isSubscribed($local)) {
+ // TRANS: OStatus remote subscription dialog error.
$this->showForm(_m('Already subscribed!'));
} elseif ($this->oprofile->subscribeLocalToRemote($user)) {
$this->successUser();
} else {
+ // TRANS: OStatus remote subscription dialog error.
$this->showForm(_m('Remote subscription failed!'));
}
}
@@ -450,6 +455,7 @@ class OStatusSubAction extends Action
function title()
{
+ // TRANS: Page title for OStatus remote subscription form
return _m('Authorize subscription');
}
diff --git a/plugins/OStatus/actions/pushhub.php b/plugins/OStatus/actions/pushhub.php
index f33690bc4..842d65e7d 100644
--- a/plugins/OStatus/actions/pushhub.php
+++ b/plugins/OStatus/actions/pushhub.php
@@ -104,7 +104,7 @@ class PushHubAction extends Action
throw new ClientException("Invalid hub.secret $secret; must be under 200 bytes.");
}
- $sub = HubSub::staticGet($sub->topic, $sub->callback);
+ $sub = HubSub::staticGet($topic, $callback);
if (!$sub) {
// Creating a new one!
$sub = new HubSub();
diff --git a/plugins/OStatus/classes/HubSub.php b/plugins/OStatus/classes/HubSub.php
index e599d83a9..3120a70f9 100644
--- a/plugins/OStatus/classes/HubSub.php
+++ b/plugins/OStatus/classes/HubSub.php
@@ -260,9 +260,15 @@ class HubSub extends Memcached_DataObject
$retries = intval(common_config('ostatus', 'hub_retries'));
}
- $data = array('sub' => clone($this),
+ // We dare not clone() as when the clone is discarded it'll
+ // destroy the result data for the parent query.
+ // @fixme use clone() again when it's safe to copy an
+ // individual item from a multi-item query again.
+ $sub = HubSub::staticGet($this->topic, $this->callback);
+ $data = array('sub' => $sub,
'atom' => $atom,
'retries' => $retries);
+ common_log(LOG_INFO, "Queuing PuSH: $this->topic to $this->callback");
$qm = QueueManager::get();
$qm->enqueue($data, 'hubout');
}
diff --git a/plugins/OStatus/classes/Magicsig.php b/plugins/OStatus/classes/Magicsig.php
index 96900d876..5a46aeeb6 100644
--- a/plugins/OStatus/classes/Magicsig.php
+++ b/plugins/OStatus/classes/Magicsig.php
@@ -146,8 +146,10 @@ class Magicsig extends Memcached_DataObject
$mod = base64_url_decode($matches[1]);
$exp = base64_url_decode($matches[2]);
- if ($matches[4]) {
+ if (!empty($matches[4])) {
$private_exp = base64_url_decode($matches[4]);
+ } else {
+ $private_exp = false;
}
$params['public_key'] = new Crypt_RSA_KEY($mod, $exp, 'public');
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php
index 7b1aec76b..a33e95d93 100644
--- a/plugins/OStatus/classes/Ostatus_profile.php
+++ b/plugins/OStatus/classes/Ostatus_profile.php
@@ -698,7 +698,7 @@ class Ostatus_profile extends Memcached_DataObject
{
// Get the canonical feed URI and check it
$discover = new FeedDiscovery();
- if ($hints['feedurl']) {
+ if (isset($hints['feedurl'])) {
$feeduri = $hints['feedurl'];
$feeduri = $discover->discoverFromFeedURL($feeduri);
} else {
@@ -1145,7 +1145,7 @@ class Ostatus_profile extends Memcached_DataObject
if (!empty($poco)) {
$url = $poco->getPrimaryURL();
- if ($url->type == 'homepage') {
+ if ($url && $url->type == 'homepage') {
$homepage = $url->value;
}
}
diff --git a/plugins/OStatus/lib/discovery.php b/plugins/OStatus/lib/discovery.php
index 388df0a28..f8449b309 100644
--- a/plugins/OStatus/lib/discovery.php
+++ b/plugins/OStatus/lib/discovery.php
@@ -94,7 +94,7 @@ class Discovery
$links = call_user_func(array($class, 'discover'), $uri);
if ($link = Discovery::getService($links, Discovery::LRDD_REL)) {
// Load the LRDD XRD
- if ($link['template']) {
+ if (!empty($link['template'])) {
$xrd_uri = Discovery::applyTemplate($link['template'], $uri);
} else {
$xrd_uri = $link['href'];
diff --git a/plugins/OStatus/lib/xrd.php b/plugins/OStatus/lib/xrd.php
index 16d27f8eb..85df26c54 100644
--- a/plugins/OStatus/lib/xrd.php
+++ b/plugins/OStatus/lib/xrd.php
@@ -53,17 +53,22 @@ class XRD
$xrd = new XRD();
$dom = new DOMDocument();
- $dom->loadXML($xml);
+ if (!$dom->loadXML($xml)) {
+ throw new Exception("Invalid XML");
+ }
$xrd_element = $dom->getElementsByTagName('XRD')->item(0);
// Check for host-meta host
- $host = $xrd_element->getElementsByTagName('Host')->item(0)->nodeValue;
+ $host = $xrd_element->getElementsByTagName('Host')->item(0);
if ($host) {
- $xrd->host = $host;
+ $xrd->host = $host->nodeValue;
}
// Loop through other elements
foreach ($xrd_element->childNodes as $node) {
+ if (!($node instanceof DOMElement)) {
+ continue;
+ }
switch ($node->tagName) {
case 'Expires':
$xrd->expires = $node->nodeValue;
@@ -156,20 +161,20 @@ class XRD
function saveLink($doc, $link)
{
$link_element = $doc->createElement('Link');
- if ($link['rel']) {
+ if (!empty($link['rel'])) {
$link_element->setAttribute('rel', $link['rel']);
}
- if ($link['type']) {
+ if (!empty($link['type'])) {
$link_element->setAttribute('type', $link['type']);
}
- if ($link['href']) {
+ if (!empty($link['href'])) {
$link_element->setAttribute('href', $link['href']);
}
- if ($link['template']) {
+ if (!empty($link['template'])) {
$link_element->setAttribute('template', $link['template']);
}
- if (is_array($link['title'])) {
+ if (!empty($link['title']) && is_array($link['title'])) {
foreach($link['title'] as $title) {
$title = $doc->createElement('Title', $title);
$link_element->appendChild($title);
diff --git a/plugins/OStatus/locale/OStatus.po b/plugins/OStatus/locale/OStatus.po
index dedc018e3..ee19cf3db 100644
--- a/plugins/OStatus/locale/OStatus.po
+++ b/plugins/OStatus/locale/OStatus.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-12-07 20:38-0800\n"
+"POT-Creation-Date: 2010-03-01 14:08-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,89 +16,297 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: tests/gettext-speedtest.php:57 FeedSubPlugin.php:76
-msgid "Feeds"
+#: actions/groupsalmon.php:51
+msgid "Can't accept remote posts for a remote group."
+msgstr ""
+
+#: actions/groupsalmon.php:123
+msgid "Can't read profile to set up group membership."
msgstr ""
-#: FeedSubPlugin.php:77
-msgid "Feed subscription options"
+#: actions/groupsalmon.php:126 actions/groupsalmon.php:169
+msgid "Groups can't join groups."
msgstr ""
-#: feedmunger.php:215
+#: actions/groupsalmon.php:153
#, php-format
-msgid "New post: \"%1$s\" %2$s"
+msgid "Could not join remote user %1$s to group %2$s."
msgstr ""
-#: actions/feedsubsettings.php:41
-msgid "Feed subscriptions"
+#: actions/groupsalmon.php:166
+msgid "Can't read profile to cancel group membership."
msgstr ""
-#: actions/feedsubsettings.php:52
-msgid ""
-"You can subscribe to feeds from other sites; updates will appear in your "
-"personal timeline."
+#: actions/groupsalmon.php:182
+#, php-format
+msgid "Could not remove remote user %1$s from group %2$s."
+msgstr ""
+
+#: actions/ostatusinit.php:40
+msgid "You can use the local subscription!"
+msgstr ""
+
+#: actions/ostatusinit.php:61
+msgid "There was a problem with your session token. Try again, please."
+msgstr ""
+
+#: actions/ostatusinit.php:79 actions/ostatussub.php:439
+msgid "Subscribe to user"
+msgstr ""
+
+#: actions/ostatusinit.php:97
+#, php-format
+msgid "Subscribe to %s"
msgstr ""
-#: actions/feedsubsettings.php:96
+#: actions/ostatusinit.php:102
+msgid "User nickname"
+msgstr ""
+
+#: actions/ostatusinit.php:103
+msgid "Nickname of the user you want to follow"
+msgstr ""
+
+#: actions/ostatusinit.php:106
+msgid "Profile Account"
+msgstr ""
+
+#: actions/ostatusinit.php:107
+msgid "Your account id (i.e. user@identi.ca)"
+msgstr ""
+
+#: actions/ostatusinit.php:110 actions/ostatussub.php:115
+#: OStatusPlugin.php:205
msgid "Subscribe"
msgstr ""
-#: actions/feedsubsettings.php:98
+#: actions/ostatusinit.php:128
+msgid "Must provide a remote profile."
+msgstr ""
+
+#: actions/ostatusinit.php:138
+msgid "Couldn't look up OStatus account profile."
+msgstr ""
+
+#: actions/ostatusinit.php:153
+msgid "Couldn't confirm remote profile address."
+msgstr ""
+
+#: actions/ostatusinit.php:171
+msgid "OStatus Connect"
+msgstr ""
+
+#: actions/ostatussub.php:68
+msgid "Address or profile URL"
+msgstr ""
+
+#: actions/ostatussub.php:70
+msgid "Enter the profile URL of a PubSubHubbub-enabled feed"
+msgstr ""
+
+#: actions/ostatussub.php:74
msgid "Continue"
msgstr ""
-#: actions/feedsubsettings.php:151
-msgid "Empty feed URL!"
+#: actions/ostatussub.php:112 OStatusPlugin.php:503
+msgid "Join"
+msgstr ""
+
+#: actions/ostatussub.php:113
+msgid "Join this group"
+msgstr ""
+
+#: actions/ostatussub.php:116
+msgid "Subscribe to this user"
+msgstr ""
+
+#: actions/ostatussub.php:137
+msgid "You are already subscribed to this user."
+msgstr ""
+
+#: actions/ostatussub.php:165
+msgid "You are already a member of this group."
msgstr ""
-#: actions/feedsubsettings.php:161
+#: actions/ostatussub.php:286
+msgid "Empty remote profile URL!"
+msgstr ""
+
+#: actions/ostatussub.php:297
+msgid "Invalid address format."
+msgstr ""
+
+#: actions/ostatussub.php:302
msgid "Invalid URL or could not reach server."
msgstr ""
-#: actions/feedsubsettings.php:164
+#: actions/ostatussub.php:304
msgid "Cannot read feed; server returned error."
msgstr ""
-#: actions/feedsubsettings.php:167
+#: actions/ostatussub.php:306
msgid "Cannot read feed; server returned an empty page."
msgstr ""
-#: actions/feedsubsettings.php:170
+#: actions/ostatussub.php:308
msgid "Bad HTML, could not find feed link."
msgstr ""
-#: actions/feedsubsettings.php:173
+#: actions/ostatussub.php:310
msgid "Could not find a feed linked from this URL."
msgstr ""
-#: actions/feedsubsettings.php:176
+#: actions/ostatussub.php:312
msgid "Not a recognized feed type."
msgstr ""
-#: actions/feedsubsettings.php:180
-msgid "Bad feed URL."
+#: actions/ostatussub.php:315
+#, php-format
+msgid "Bad feed URL: %s %s"
+msgstr ""
+
+#. TRANS: OStatus remote group subscription dialog error.
+#: actions/ostatussub.php:336
+msgid "Already a member!"
msgstr ""
-#: actions/feedsubsettings.php:188
-msgid "Feed is not PuSH-enabled; cannot subscribe."
+#. TRANS: OStatus remote group subscription dialog error.
+#: actions/ostatussub.php:346
+msgid "Remote group join failed!"
msgstr ""
-#: actions/feedsubsettings.php:208
-msgid "Feed subscription failed! Bad response from hub."
+#. TRANS: OStatus remote group subscription dialog error.
+#: actions/ostatussub.php:350
+msgid "Remote group join aborted!"
msgstr ""
-#: actions/feedsubsettings.php:218
+#. TRANS: OStatus remote subscription dialog error.
+#: actions/ostatussub.php:356
msgid "Already subscribed!"
msgstr ""
-#: actions/feedsubsettings.php:220
-msgid "Feed subscribed!"
+#. TRANS: OStatus remote subscription dialog error.
+#: actions/ostatussub.php:361
+msgid "Remote subscription failed!"
msgstr ""
-#: actions/feedsubsettings.php:222
-msgid "Feed subscription failed!"
+#. TRANS: Page title for OStatus remote subscription form
+#: actions/ostatussub.php:459
+msgid "Authorize subscription"
+msgstr ""
+
+#: actions/ostatussub.php:470
+msgid ""
+"You can subscribe to users from other supported sites. Paste their address "
+"or profile URI below:"
+msgstr ""
+
+#: classes/Ostatus_profile.php:789
+#, php-format
+msgid "Tried to update avatar for unsaved remote profile %s"
msgstr ""
-#: actions/feedsubsettings.php:231
-msgid "Previewing feed:"
+#: classes/Ostatus_profile.php:797
+#, php-format
+msgid "Unable to fetch avatar from %s"
+msgstr ""
+
+#: lib/salmonaction.php:41
+msgid "This method requires a POST."
+msgstr ""
+
+#: lib/salmonaction.php:45
+msgid "Salmon requires application/magic-envelope+xml"
+msgstr ""
+
+#: lib/salmonaction.php:55
+msgid "Salmon signature verification failed."
+msgstr ""
+
+#: lib/salmonaction.php:66
+msgid "Salmon post must be an Atom entry."
+msgstr ""
+
+#: lib/salmonaction.php:114
+msgid "Unrecognized activity type."
+msgstr ""
+
+#: lib/salmonaction.php:122
+msgid "This target doesn't understand posts."
+msgstr ""
+
+#: lib/salmonaction.php:127
+msgid "This target doesn't understand follows."
+msgstr ""
+
+#: lib/salmonaction.php:132
+msgid "This target doesn't understand unfollows."
+msgstr ""
+
+#: lib/salmonaction.php:137
+msgid "This target doesn't understand favorites."
+msgstr ""
+
+#: lib/salmonaction.php:142
+msgid "This target doesn't understand unfavorites."
+msgstr ""
+
+#: lib/salmonaction.php:147
+msgid "This target doesn't understand share events."
+msgstr ""
+
+#: lib/salmonaction.php:152
+msgid "This target doesn't understand joins."
+msgstr ""
+
+#: lib/salmonaction.php:157
+msgid "This target doesn't understand leave events."
+msgstr ""
+
+#: OStatusPlugin.php:319
+#, php-format
+msgid "Sent from %s via OStatus"
+msgstr ""
+
+#: OStatusPlugin.php:371
+msgid "Could not set up remote subscription."
+msgstr ""
+
+#: OStatusPlugin.php:487
+msgid "Could not set up remote group membership."
+msgstr ""
+
+#: OStatusPlugin.php:504
+#, php-format
+msgid "%s has joined group %s."
+msgstr ""
+
+#: OStatusPlugin.php:512
+msgid "Failed joining remote group."
+msgstr ""
+
+#: OStatusPlugin.php:553
+msgid "Leave"
+msgstr ""
+
+#: OStatusPlugin.php:554
+#, php-format
+msgid "%s has left group %s."
+msgstr ""
+
+#: OStatusPlugin.php:685
+msgid "Subscribe to remote user"
+msgstr ""
+
+#: OStatusPlugin.php:726
+msgid "Profile update"
+msgstr ""
+
+#: OStatusPlugin.php:727
+#, php-format
+msgid "%s has updated their profile page."
+msgstr ""
+
+#: tests/gettext-speedtest.php:57
+msgid "Feeds"
msgstr ""
diff --git a/plugins/OStatus/scripts/updateostatus.php b/plugins/OStatus/scripts/updateostatus.php
new file mode 100644
index 000000000..d553a7d62
--- /dev/null
+++ b/plugins/OStatus/scripts/updateostatus.php
@@ -0,0 +1,127 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - a 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/>.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
+
+$shortoptions = 'i:n:a';
+$longoptions = array('id=', 'nickname=', 'all');
+
+$helptext = <<<END_OF_UPDATEOSTATUS_HELP
+updateostatus.php [options]
+update the OMB subscriptions of a user to use OStatus if possible
+
+ -i --id ID of user to update
+ -n --nickname nickname of the user to update
+ -a --all update all
+
+END_OF_UPDATEOSTATUS_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+try {
+ $user = null;
+
+ if (have_option('i', 'id')) {
+ $id = get_option_value('i', 'id');
+ $user = User::staticGet('id', $id);
+ if (empty($user)) {
+ throw new Exception("Can't find user with id '$id'.");
+ }
+ updateProfileURL($user);
+ } else if (have_option('n', 'nickname')) {
+ $nickname = get_option_value('n', 'nickname');
+ $user = User::staticGet('nickname', $nickname);
+ if (empty($user)) {
+ throw new Exception("Can't find user with nickname '$nickname'");
+ }
+ updateProfileURL($user);
+ } else if (have_option('a', 'all')) {
+ $user = new User();
+ if ($user->find()) {
+ while ($user->fetch()) {
+ updateOStatus($user);
+ }
+ }
+ } else {
+ show_help();
+ exit(1);
+ }
+} catch (Exception $e) {
+ print $e->getMessage()."\n";
+ exit(1);
+}
+
+function updateOStatus($user)
+{
+ if (!have_option('q', 'quiet')) {
+ echo "{$user->nickname}...";
+ }
+
+ $up = $user->getProfile();
+
+ $sp = $user->getSubscriptions();
+
+ $rps = array();
+
+ while ($sp->fetch()) {
+ $remote = Remote_profile::staticGet('id', $sp->id);
+
+ if (!empty($remote)) {
+ $rps[] = clone($sp);
+ }
+ }
+
+ if (!have_option('q', 'quiet')) {
+ echo count($rps) . "\n";
+ }
+
+ foreach ($rps as $rp) {
+ try {
+ if (!have_option('q', 'quiet')) {
+ echo "Checking {$rp->nickname}...";
+ }
+
+ $op = Ostatus_profile::ensureProfile($rp->profileurl);
+
+ if (empty($op)) {
+ echo "can't convert.\n";
+ continue;
+ } else {
+ if (!have_option('q', 'quiet')) {
+ echo "Converting...";
+ }
+ Subscription::cancel($up, $rp);
+ Subscription::start($up, $op->localProfile());
+ if (!have_option('q', 'quiet')) {
+ echo "done.\n";
+ }
+ }
+
+ } catch (Exception $e) {
+ if (!have_option('q', 'quiet')) {
+ echo "fail.\n";
+ }
+ continue;
+ common_log(LOG_WARNING, "Couldn't convert OMB subscription (" . $up->nickname . ", " . $rp->nickname .
+ ") to OStatus: " . $e->getMessage());
+ continue;
+ }
+ }
+}