]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fix issues with non-subscribed Ostatus_profiles
authorMikael Nordfeldth <mmn@hethane.se>
Tue, 2 May 2017 07:14:30 +0000 (09:14 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Tue, 2 May 2017 07:14:30 +0000 (09:14 +0200)
plugins/OStatus/OStatusPlugin.php

index d12881cde4a1fd07e7c6507bb70881da26e3e0e8..18e8539eb4aa7b37e8a13d0fb604e17a38f78827 100644 (file)
@@ -1200,6 +1200,22 @@ class OStatusPlugin extends Plugin
         if ($profile->isLocal()) {
             return true;
         }
+        try {
+            $oprofile = Ostatus_profile::fromProfile($profile);
+        } catch (NoResultException $e) {
+            // Not a remote Ostatus_profile! Maybe some other network
+            // that has imported a non-local user?
+            return true;
+        }
+        try {
+            $feedsub = $oprofile->getFeedSub();
+        } catch (NoResultException $e) {
+            // No WebSub subscription has been attempted or exists for this profile
+            // which is the case, say for remote profiles that are only included
+            // via mentions or repeat/share.
+            return true;
+        }
+
         $websub_states = [
                 'subscribe' => _m('Pending'),
                 'active'    => _m('Active'),
@@ -1207,8 +1223,6 @@ class OStatusPlugin extends Plugin
                 'inactive'  => _m('Inactive'),
             ];
         $out->elementStart('dl', 'entity_tags ostatus_profile');
-        $oprofile = Ostatus_profile::fromProfile($profile);
-        $feedsub = $oprofile->getFeedSub();
         $out->element('dt', null, _m('WebSub'));
         $out->element('dd', null, $websub_states[$feedsub->sub_state]);
         $out->elementEnd('dl');