]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
SHARE activities would not be imported from federated instances for local notices
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 21 Oct 2013 20:28:17 +0000 (22:28 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 21 Oct 2013 21:25:43 +0000 (23:25 +0200)
"[...] posts _local_ users (like you) make won't get data about "repeated by"
from federated users"

This was because the ActivityObject would processShare where the shared object
has a _local_ 'actor' URI. Ostatus_profile would complain this meant that a
"Local user cannot be referenced as remote.".

So we see if the shared activity object's id (URI) is in our Notice table, so
we don't have to processActivity - and can skip ensureActivityObjectProfile.

plugins/OStatus/classes/Ostatus_profile.php

index 6ad3023cb2150deaba7786ddd01d47deb995962e..a862c978d27d0005f880b161e0c0a6eff52011bd 100644 (file)
@@ -466,6 +466,7 @@ class Ostatus_profile extends Managed_DataObject
         return $this->processActivity($activity, $source);
     }
 
+    // TODO: Make this throw an exception
     public function processActivity($activity, $source)
     {
         $notice = null;
@@ -529,18 +530,23 @@ class Ostatus_profile extends Managed_DataObject
             throw new ClientException(_m('Can only handle shared activities.'));
         }
 
-        $other = Ostatus_profile::ensureActivityObjectProfile($shared->actor);
-
-        // Save the item (or check for a dupe)
-
-        $sharedNotice = $other->processActivity($shared, $method);
+        // First check if we have the shared activity. This has to be done first, because
+        // we can't use these functions to "ensureActivityObjectProfile" of a local user,
+        // who might be the creator of the shared activity in question.
+        $sharedId = ($shared->id) ? $shared->id : $shared->objects[0]->id;
+        $sharedNotice = Notice::getKV('uri', $sharedId);
+        if (!($sharedNotice instanceof Notice)) {
+            // If no local notice is found, process it!
+            // TODO: Remember to check Deleted_notice!
+            $other = Ostatus_profile::ensureActivityObjectProfile($shared->actor);
+            $sharedNotice = $other->processActivity($shared, $method);
+        }
 
-        if (empty($sharedNotice)) {
-            $sharedId = ($shared->id) ? $shared->id : $shared->objects[0]->id;
+        if (!($sharedNotice instanceof Notice)) {
+            // And if we apparently can't get the shared notice, we'll abort the whole thing.
             // TRANS: Client exception thrown when saving an activity share fails.
             // TRANS: %s is a share ID.
-            throw new ClientException(sprintf(_m('Failed to save activity %s.'),
-                                              $sharedId));
+            throw new ClientException(sprintf(_m('Failed to save activity %s.'), $sharedId));
         }
 
         // The id URI will be used as a unique identifier for for the notice,