From 3ff3abb247062ed61486930ed1203c286b1378b2 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 1 Mar 2010 12:55:51 -0500 Subject: [PATCH] Script to convert OMB subscriptions to OStatus subscriptions --- plugins/OStatus/scripts/updateostatus.php | 102 ++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 plugins/OStatus/scripts/updateostatus.php 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; + } + } +} -- 2.39.5