From: Mikael Nordfeldth Date: Mon, 21 Oct 2013 20:28:17 +0000 (+0200) Subject: SHARE activities would not be imported from federated instances for local notices X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ba46c3d360c52b5363ce0d63828771d5c57be6e2;p=quix0rs-gnu-social.git SHARE activities would not be imported from federated instances for local notices "[...] 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. --- diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 6ad3023cb2..a862c978d2 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -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,