Receiving Share activity fixes

Forgot to translate 'self' to 'Ostatus_profile' etc.
This commit is contained in:
Mikael Nordfeldth 2015-03-12 16:59:50 +01:00
parent dcfcceb6f2
commit dc31a3d7d6

View File

@ -98,34 +98,35 @@ class SharePlugin extends ActivityVerbHandlerPlugin
throw new ClientException(_m('Shared activity does not have an id')); throw new ClientException(_m('Shared activity does not have an id'));
} }
// First check if we have the shared activity. This has to be done first, because try {
// we can't use these functions to "ensureActivityObjectProfile" of a local user, // First check if we have the shared activity. This has to be done first, because
// who might be the creator of the shared activity in question. // we can't use these functions to "ensureActivityObjectProfile" of a local user,
$sharedNotice = Notice::getKV('uri', $sharedId); // who might be the creator of the shared activity in question.
if (!$sharedNotice instanceof Notice) { $sharedNotice = Notice::getByUri($sharedUri);
} catch (NoResultException $e) {
// If no locally stored notice is found, process it! // If no locally stored notice is found, process it!
// TODO: Remember to check Deleted_notice! // TODO: Remember to check Deleted_notice!
// TODO: If a post is shared that we can't retrieve - what to do? // TODO: If a post is shared that we can't retrieve - what to do?
try { $other = Ostatus_profile::ensureActivityObjectProfile($shared->actor);
$other = self::ensureActivityObjectProfile($shared->actor); $sharedNotice = $other->processActivity($shared, 'push'); // FIXME: push/salmon/what?
$sharedNotice = $other->processActivity($shared, $method); if (!$sharedNotice instanceof Notice) {
if (!$sharedNotice instanceof Notice) { // And if we apparently can't get the shared notice, we'll abort the whole thing.
// 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: Client exception thrown when saving an activity share fails. // TRANS: %s is a share ID.
// TRANS: %s is a share ID. throw new ClientException(sprintf(_m('Failed to save activity %s.'), $sharedUri));
throw new ClientException(sprintf(_m('Failed to save activity %s.'), $sharedId));
}
} catch (FeedSubException $e) {
// Remote feed could not be found or verified, should we
// transform this into an "RT @user Blah, blah, blah..."?
common_log(LOG_INFO, __METHOD__ . ' got a ' . get_class($e) . ': ' . $e->getMessage());
return null;
} }
} catch (FeedSubException $e) {
// Remote feed could not be found or verified, should we
// transform this into an "RT @user Blah, blah, blah..."?
common_log(LOG_INFO, __METHOD__ . ' got a ' . get_class($e) . ': ' . $e->getMessage());
return false;
} }
// We don't have to save a repeat in a separate table, we can // 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. // find repeats by just looking at the notice.repeat_of field.
// By returning true here instead of something that evaluates
// to false, we show that we have processed everything properly.
return true; return true;
} }