From c5a5eaf288a55539f91bd51e980770b9a2d82087 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sat, 11 Jul 2015 19:46:01 +0200 Subject: [PATCH] Do we update feeduri and salmonuri for Ostatus_profile now? When changing from HTTP to HTTPS, following up on commit 59763ceecb33ebf842829cac15f922fa19047de2 where http to https Ostatus_profile URI changing was first introduced. --- plugins/OStatus/classes/Ostatus_profile.php | 32 +++++++++++++++++++++ plugins/OStatus/lib/salmonaction.php | 7 +---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index cb961dc96b..1c4428b16d 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -1977,6 +1977,38 @@ class Ostatus_profile extends Managed_DataObject return $oprofile->localProfile(); } + + public function updateUriKeys($profile_uri, array $hints=array()) + { + $orig = clone($this); + + common_debug('URIFIX These identities both say they are each other: "'.$orig->uri.'" and "'.$profile_uri.'"'); + $this->uri = $profile_uri; + + if (array_key_exists('feedurl', $hints)) { + if (!empty($this->feeduri)) { + common_debug('URIFIX Changing FeedSub ['.$feedsub->id.'] feeduri "'.$feedsub->uri.'" to "'.$hints['feedurl']); + $feedsub = FeedSub::getKV('uri', $this->feeduri); + $feedorig = clone($feedsub); + $feedsub->uri = $hints['feedurl']; + $feedsub->updateWithKeys($feedorig); + } else { + common_debug('URIFIX Old Ostatus_profile did not have feedurl set, ensuring feed: '.$hints['feedurl']); + FeedSub::ensureFeed($hints['feedurl']); + } + $this->feeduri = $hints['feedurl']; + } + if (array_key_exists('salmon', $hints)) { + common_debug('URIFIX Changing Ostatus_profile salmonuri from "'.$this->salmonuri.'" to "'.$hints['salmon'].'"'); + $this->salmonuri = $hints['salmon']; + } + + common_debug('URIFIX Updating Ostatus_profile URI for '.$orig->uri.' to '.$this->uri); + $this->updateWithKeys($orig, 'uri'); // 'uri' is the primary key column + + common_debug('URIFIX Subscribing/renewing feedsub for Ostatus_profile '.$this->uri); + $this->subscribe(); + } } /** diff --git a/plugins/OStatus/lib/salmonaction.php b/plugins/OStatus/lib/salmonaction.php index 5193d302f1..320ea6cdfa 100644 --- a/plugins/OStatus/lib/salmonaction.php +++ b/plugins/OStatus/lib/salmonaction.php @@ -259,12 +259,7 @@ class SalmonAction extends Action // Step 4: Is the newly introduced https://example.com/user/1 URI in the list of aliases // presented by http://example.com/user/1 (i.e. do they both say they are the same identity?) if (in_array($e->object_uri, $doublecheck_aliases)) { - common_debug('URIFIX These identities both say they are each other: "'.$aliased_uri.'" and "'.$e->object_uri.'"'); - $orig = clone($oprofile); - $oprofile->uri = $e->object_uri; - common_debug('URIFIX Updating Ostatus_profile URI for '.$aliased_uri.' to '.$oprofile->uri); - $oprofile->updateWithKeys($orig, 'uri'); // 'uri' is the primary key column - unset($orig); + $oprofile->updateUriKeys($e->object_uri, DiscoveryHints::fromXRD($xrd)); $this->oprofile = $oprofile; break; // don't iterate through aliases anymore }