]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Notice properties set in bad order on activityobject saving
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 12 Mar 2015 21:17:08 +0000 (22:17 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 12 Mar 2015 21:17:08 +0000 (22:17 +0100)
classes/Notice.php
plugins/Favorite/FavoritePlugin.php
plugins/Share/SharePlugin.php

index 1b2b631b04a23bfbe2da1ca491cdca13f6a31c5c..541a72fb09ddecbaab1d1f66dfa1f184e1e52798 100644 (file)
@@ -902,6 +902,12 @@ class Notice extends Managed_DataObject
                 $stored->insert();    // throws exception on error
                 $orig = clone($stored); // for updating later in this try clause
 
+                $object = null;
+                Event::handle('StoreActivityObject', array($act, $stored, $options, &$object));
+                if (empty($object)) {
+                    throw new ServerException('Unsuccessful call to StoreActivityObject '.$stored->uri . ': '.$act->asString());
+                }
+
                 // If it's not part of a conversation, it's
                 // the beginning of a new conversation.
                 if (empty($stored->conversation)) {
@@ -910,12 +916,6 @@ class Notice extends Managed_DataObject
                     $stored->conversation = $conv->id;
                 }
 
-                $object = null;
-                Event::handle('StoreActivityObject', array($act, $stored, $options, &$object));
-                if (empty($object)) {
-                    throw new ServerException('Unsuccessful call to StoreActivityObject '.$stored->uri . ': '.$act->asString());
-                }
-                $stored->object_type = ActivityUtils::resolveUri($object->getObjectType(), true);
                 $stored->update($orig);
             } catch (Exception $e) {
                 if (empty($stored->id)) {
index 55716016bd6448824061ed52fa3f9203c5f6182b..eb73bbe43c9a4d40137688bea56894868c679bda 100644 (file)
@@ -194,6 +194,8 @@ class FavoritePlugin extends ActivityVerbHandlerPlugin
         $actobj = $act->objects[0];
 
         $object = Fave::saveActivityObject($actobj, $stored);
+        $stored->object_type = ActivityUtils::resolveUri($object->getObjectType(), true);
+
         return $object;
     }
 
index bfcf931a8ed520a58c06529b2803a3d9e536ed03..671214b1d65e742a9254a1b0bd51f795f5b0a1e8 100644 (file)
@@ -40,6 +40,14 @@ class SharePlugin extends ActivityVerbHandlerPlugin
         return array(ActivityVerb::SHARE);
     }
 
+    // Share is a bit special and $act->objects[0] should be an Activity
+    // instead of ActivityObject! Therefore also $act->objects[0]->type is not set.
+    public function isMyActivity(Activity $act) {
+        return (count($act->objects) == 1
+            && ($act->objects[0] instanceof Activity)
+            && $this->isMyVerb($act->verb));
+    }
+
     public function onRouterInitialized(URLMapper $m)
     {
         // Web UI actions
@@ -125,6 +133,8 @@ class SharePlugin extends ActivityVerbHandlerPlugin
         // Setting this here because when the algorithm gets back to
         // Notice::saveActivity it will update the Notice object.
         $stored->repeat_of = $sharedNotice->getID();
+        $stored->conversation = $sharedNotice->conversation;
+        $stored->object_type = ActivityUtils::resolveUri(ActivityObject::ACTIVITY, true);
 
         // We don't have to save a repeat in a separate table, we can
         // find repeats by just looking at the notice.repeat_of field.