From 935495415b9e8ddf5edab5a588f81f72d4a65c80 Mon Sep 17 00:00:00 2001 From: Diogo Cordeiro Date: Mon, 6 Aug 2018 19:57:28 +0100 Subject: [PATCH] Don't break when notice grabber fails It's better to fragment the integrity of a note than to fail publishing a note --- actions/apactorfollowers.php | 2 +- actions/apactorfollowing.php | 2 +- classes/Activitypub_notice.php | 10 +++++++--- classes/Activitypub_profile.php | 2 +- utils/postman.php | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/actions/apactorfollowers.php b/actions/apactorfollowers.php index dd7c796..a9d8cc1 100755 --- a/actions/apactorfollowers.php +++ b/actions/apactorfollowers.php @@ -108,7 +108,7 @@ class apActorFollowersAction extends ManagedAction } /** - * Generates a list of followers for a given profile. + * Generates a list of stalkers for a given profile. * * @author Diogo Cordeiro * @param Profile $profile diff --git a/actions/apactorfollowing.php b/actions/apactorfollowing.php index 24f4221..b31ff6d 100755 --- a/actions/apactorfollowing.php +++ b/actions/apactorfollowing.php @@ -108,7 +108,7 @@ class apActorFollowingAction extends ManagedAction } /** - * Generates a list of people following given profile. + * Generates the list of those a given profile is stalking. * * @author Diogo Cordeiro * @param Profile $profile diff --git a/classes/Activitypub_notice.php b/classes/Activitypub_notice.php index 864fafc..9d78401 100755 --- a/classes/Activitypub_notice.php +++ b/classes/Activitypub_notice.php @@ -188,11 +188,15 @@ class Activitypub_notice extends Managed_DataObject if (isset($settings['inReplyTo'])) { try { $inReplyTo = ActivityPubPlugin::grab_notice_from_url($settings['inReplyTo']); + $act->context->replyToID = $inReplyTo->getUri(); + $act->context->replyToUrl = $inReplyTo->getUrl(); } catch (Exception $e) { - throw new Exception('Invalid Object inReplyTo value: '.$e->getMessage()); + // It failed to grab, maybe we got this note from another source + // (e.g.: OStatus) that handles this differently or we really + // failed to get it... + // Welp, nothing that we can do about, let's + // just fake we don't have such notice. } - $act->context->replyToID = $inReplyTo->getUri(); - $act->context->replyToUrl = $inReplyTo->getUrl(); } else { $inReplyTo = null; } diff --git a/classes/Activitypub_profile.php b/classes/Activitypub_profile.php index 35cd0b4..6def728 100755 --- a/classes/Activitypub_profile.php +++ b/classes/Activitypub_profile.php @@ -243,7 +243,7 @@ class Activitypub_profile extends Managed_DataObject $inboxes = Activitypub_explorer::get_actor_inboxes_uri($url); if ($inboxes == null) { - throw new Exception ('This is not an ActivityPub user thus AProfile is politely refusing to proceed.'); + throw new Exception('This is not an ActivityPub user thus AProfile is politely refusing to proceed.'); } $aprofile->created = $aprofile->modified = common_sql_now(); diff --git a/utils/postman.php b/utils/postman.php index 600a7fe..ea467a7 100755 --- a/utils/postman.php +++ b/utils/postman.php @@ -68,7 +68,7 @@ class Activitypub_postman $followers = apActorFollowersAction::generate_followers($this->actor, 0, null); foreach ($followers as $sub) { try { - $to[]= Activitypub_profile::from_profile($discovery->lookup($sub)[0]); + $to[]= Activitypub_profile::from_profile($discovery->lookup($sub)[0]); } catch (Exception $e) { // Not an ActivityPub Remote Follower, let it go }