define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
-$shortoptions = 'u:a';
-$longoptions = array('uri=', 'all');
+$shortoptions = 'u:af';
+$longoptions = array('uri=', 'all', 'force');
$helptext = <<<UPDATE_OSTATUS_PROFILES
update_ostatus_profiles.php [options]
-u --uri OStatus profile URI to update
-a --all update all
+ -f --force Force update (despite identical avatar URLs etc.)
UPDATE_OSTATUS_PROFILES;
// Check if we have a non-canonical URL
- $finalUrl = $response->getUrl();
+ $finalUrl = $response->getEffectiveUrl();
if ($finalUrl != $profile_url) {
$hints['profileurl'] = $finalUrl;
function pullOstatusProfile($uri) {
$oprofile = null;
+ $validate = new Validate();
- if (Validate::email($uri)) {
+ if ($validate->email($uri)) {
$oprofile = LooseOstatusProfile::updateWebfinger($uri);
- } else if (Validate::uri($uri)) {
+ } else if ($validate->uri($uri)) {
$oprofile = LooseOstatusProfile::updateProfileURL($uri);
} else {
print "Sorry, we could not reach the address: $uri\n";
exit(1);
}
+$forceUpdates = have_option('f', 'force');
+
$cnt = $lop->find();
if (!empty($cnt)) {
$orig = clone($lop);
$lop->avatar = $oprofile->avatar;
$lop->update($orig);
- $lop->updateAvatar($oprofile->avatar);
+ $lop->updateAvatar($oprofile->avatar, $forceUpdates);
if (!$quiet) { print "Done.\n"; }
}
} catch (Exception $e) {