From: Evan Prodromou Date: Mon, 1 Mar 2010 17:55:51 +0000 (-0500) Subject: Script to convert OMB subscriptions to OStatus subscriptions X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3ff3abb247062ed61486930ed1203c286b1378b2;p=quix0rs-gnu-social.git Script to convert OMB subscriptions to OStatus subscriptions --- diff --git a/plugins/OStatus/scripts/updateostatus.php b/plugins/OStatus/scripts/updateostatus.php new file mode 100644 index 0000000000..8b10817040 --- /dev/null +++ b/plugins/OStatus/scripts/updateostatus.php @@ -0,0 +1,102 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..')); + +$shortoptions = 'i:n:a'; +$longoptions = array('id=', 'nickname=', 'all'); + +$helptext = <<find()) { + while ($user->fetch()) { + updateOStatus($user); + } + } + } else { + show_help(); + exit(1); + } +} catch (Exception $e) { + print $e->getMessage()."\n"; + exit(1); +} + +function updateOStatus($user) +{ + $up = $user->getProfile(); + + $sp = $user->getSubscriptions(); + + $rps = array(); + + while ($sp->fetch()) { + $remote = Remote_profile::staticGet('id', $sp->id); + + if (!empty($remote)) { + $rps[] = clone($sp); + } + } + + foreach ($rps as $rp) { + try { + $op = Ostatus_profile::ensureProfile($rp->profileurl); + + if (!empty($op)) { + Subscription::cancel($up, $rp); + Subscription::start($up, $op->localProfile()); + } + + } catch (Exception $e) { + common_log(LOG_WARNING, "Couldn't convert OMB subscription (" . $up->nickname . ", " . $rp->nickname . + ") to OStatus: " . $e->getMessage()); + continue; + } + } +}