]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
More Activity-based reasoning for saveActivity in Notice
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 14 Jul 2014 21:54:58 +0000 (23:54 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 14 Jul 2014 21:54:58 +0000 (23:54 +0200)
If we can, get the activity ID from the activity itself, instead of the
supplied $options array.

classes/Notice.php
lib/activity.php
plugins/Favorite/FavoritePlugin.php

index 88a1394b88b3a8b7767c0cec73fa7c90c69bc5b7..89f41ad79b1335c5334ede77a45d5029f839b3ce 100644 (file)
@@ -712,24 +712,22 @@ class Notice extends Managed_DataObject
                                         'and post again in a few minutes.'));
         }
 
-/* This interferes with stuff like Favorites from old StatusNet installations (first object in objects is the favored notice)
         // Get ActivityObject properties
-        $actobj = count($act->objects)==1 ? $act->objects[0] : null;
-        if (!is_null($actobj) && $actobj->id) {
-            $options['uri'] = $actobj->id;
-            if ($actobj->link) {
-                $options['url'] = $actobj->link;
-            } elseif ($act->link) {
-                $options['url'] = $act->link;
-            } elseif (preg_match('!^https?://!', $actobj->id)) {
-                $options['url'] = $actobj->id;
-            }
-        } else {
+        if (!empty($act->id)) {
             // implied object
             $options['uri'] = $act->id;
             $options['url'] = $act->link;
+        } else {
+            $actobj = count($act->objects)==1 ? $act->objects[0] : null;
+            if (!is_null($actobj) && !empty($actobj->id)) {
+                $options['uri'] = $actobj->id;
+                if ($actobj->link) {
+                    $options['url'] = $actobj->link;
+                } elseif (preg_match('!^https?://!', $actobj->id)) {
+                    $options['url'] = $actobj->id;
+                }
+            }
         }
-*/
 
         $defaults = array(
                           'groups'   => array(),
index 8be37c568166269d9c7e5322a00c6ed681a5b5f9..6fd04c4db1709e16862475de53ad6da4c463b090 100644 (file)
@@ -244,6 +244,9 @@ class Activity
 
         if (!empty($targetEl)) {
             $this->target = new ActivityObject($targetEl);
+        } elseif (ActivityUtils::compareTypes($this->verb, array(ActivityVerb::FAVORITE))) {
+            // StatusNet didn't send a 'target' for their Favorite atom entries
+            $this->target = clone($this->objects[0]);
         }
 
         $this->summary = ActivityUtils::childContent($entry, 'summary');
index baa8df43c441b5261fdb2e009b2afb0538648d86..cc1ad0705a717cac14eca005e37d260308760023 100644 (file)
@@ -179,9 +179,6 @@ class FavoritePlugin extends ActivityHandlerPlugin
         if (!isset($options['created'])) {
             $options['created'] = !empty($act->time) ? common_sql_date($act->time) : common_sql_now();
         }
-        if (!isset($options['uri'])) {
-            $options['uri'] = !empty($act->id) ? $act->id : $act->selfLink;
-        }
 
         // We must have an objects[0] here because in isMyActivity we require the count to be == 1
         $actobj = $act->objects[0];