]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/classes/Ostatus_profile.php
Do we update feeduri and salmonuri for Ostatus_profile now?
[quix0rs-gnu-social.git] / plugins / OStatus / classes / Ostatus_profile.php
index cb961dc96ba8f164bf2105e5d51d0134339b82e2..1c4428b16df7ed17e1e90949c9d452ef9f5f383e 100644 (file)
@@ -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();
+    }
 }
 
 /**