]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Update Profile Data script fixes, might work for groups too now
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 28 Mar 2016 14:19:47 +0000 (16:19 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 28 Mar 2016 14:19:47 +0000 (16:19 +0200)
lib/activityutils.php
plugins/OStatus/classes/Ostatus_profile.php
plugins/OStatus/scripts/update-profile-data.php

index b86dd6590928501db8080a819f73037666f4b68c..dcccbb8d878dae2e8960e75b854e711d832286ac 100644 (file)
@@ -301,7 +301,7 @@ class ActivityUtils
         return false;
     }
 
-    static function getFeedAuthor($feedEl)
+    static function getFeedAuthor(DOMDocument $feedEl)
     {
         // Try old and deprecated activity:subject
 
index 5673d51457970adc99bb110e56743e59ae5a1e93..e8ac16fb1d553b2e36b75c617750d9a762f48649 100644 (file)
@@ -1281,6 +1281,12 @@ class Ostatus_profile extends Managed_DataObject
      */
     public function updateFromActivityObject(ActivityObject $object, array $hints=array())
     {
+        if (self::getActivityObjectProfileURI($actorObj) !== $this->getUri()) {
+            common_log(LOG_ERR, 'Trying to update profile with URI '._ve($this->getUri()).' from ActivityObject with URI: '._ve(self::getActivityObjectProfileURI($actorObj)));
+            // FIXME: Maybe not AuthorizationException?
+            throw new AuthorizationException('Trying to update profile from ActivityObject with different URI.');
+        }
+
         if ($this->isGroup()) {
             $group = $this->localGroup();
             self::updateGroup($group, $object, $hints);
index e713ee36fecc66bc08d041e02a03866f4d7e1d4f..5b3e00e9fc45440aac838a55b1a811ac070e7f8f 100755 (executable)
@@ -62,15 +62,16 @@ function fixProfile(Ostatus_profile $oprofile) {
         echo "Updating profile from feed: $feedurl\n";
         $dom = new DOMDocument();
         if ($dom->loadXML($response->getBody())) {
-            $feed = $dom->documentElement;
-            $entries = $dom->getElementsByTagNameNS(Activity::ATOM, 'entry');
-            if ($entries->length) {
-                $entry = $entries->item(0);
-                $activity = new Activity($entry, $feed);
-                $oprofile->checkAuthorship($activity);
+            if ($dom->documentElement->tagName !== 'feed') {
+                echo "  (no <feed> element in feed URL response; skipping)\n";
+                return false;
+            }
+            $actorObj = ActivityUtils::getFeedAuthor($dom->documentElement);
+            if ($actorObj) {
+                $oprofile->updateFromActivityObject($actorObj);
                 echo "  (ok)\n";
             } else {
-                echo "  (no entry; skipping)\n";
+                echo "  (no author on feed; skipping)\n";
                 return false;
             }
         } else {