]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/OStatusPlugin.php
don't send private notices over OStatus
[quix0rs-gnu-social.git] / plugins / OStatus / OStatusPlugin.php
index f846a2fc8b94c46b6053afb39cb8ca60d36ff85b..26b7ade64dbf2203525f35880aaa4040b55e0025 100644 (file)
@@ -111,7 +111,9 @@ class OStatusPlugin extends Plugin
      */
     function onStartEnqueueNotice($notice, &$transports)
     {
-        if ($notice->isLocal()) {
+        // FIXME: we don't do privacy-controlled OStatus updates yet.
+        // once that happens, finer grain of control here.
+        if ($notice->isLocal() && $notice->inScope(null)) {
             // put our transport first, in case there's any conflict (like OMB)
             array_unshift($transports, 'ostatus');
         }
@@ -145,12 +147,10 @@ class OStatusPlugin extends Plugin
             $user = $feed->getUser();
             $id   = $user->id;
             $profile = $user->getProfile();
-            $feed->setActivitySubject($profile->asActivityNoun('subject'));
         } else if ($feed instanceof AtomGroupNoticeFeed) {
             $salmonAction = 'groupsalmon';
             $group = $feed->getGroup();
             $id = $group->id;
-            $feed->setActivitySubject($group->asActivitySubject());
         } else {
             return true;
         }
@@ -230,7 +230,7 @@ class OStatusPlugin extends Plugin
         return false;
     }
 
-    function onStartGroupSubscribe($output, $group)
+    function onStartGroupSubscribe($widget, $group)
     {
         $cur = common_current_user();
 
@@ -238,7 +238,7 @@ class OStatusPlugin extends Plugin
             // Add an OStatus subscribe
             $url = common_local_url('ostatusinit',
                                     array('group' => $group->nickname));
-            $output->element('a', array('href' => $url,
+            $widget->out->element('a', array('href' => $url,
                                         'class' => 'entity_remote_subscribe'),
                                 // TRANS: Link description for link to join a remote group.
                                 _m('Join'));
@@ -421,12 +421,12 @@ class OStatusPlugin extends Plugin
     }
 
     function onEndShowStatusNetStyles($action) {
-        $action->cssLink('plugins/OStatus/theme/base/css/ostatus.css');
+        $action->cssLink($this->path('theme/base/css/ostatus.css'));
         return true;
     }
 
     function onEndShowStatusNetScripts($action) {
-        $action->script('plugins/OStatus/js/ostatus.js');
+        $action->script($this->path('js/ostatus.js'));
         return true;
     }
 
@@ -677,7 +677,7 @@ class OStatusPlugin extends Plugin
      * it'll be left with a stray membership record.
      *
      * @param User_group $group
-     * @param User $user
+     * @param Profile $user
      *
      * @return mixed hook return value
      */
@@ -994,17 +994,29 @@ class OStatusPlugin extends Plugin
         return false;
     }
 
-    function onStartGetProfileFromURI($uri, &$profile) {
+    function onStartGetProfileFromURI($uri, &$profile)
+    {
+        // Don't want to do Web-based discovery on our own server,
+        // so we check locally first.
 
-        // XXX: do discovery here instead (OStatus_profile::ensureProfileURI($uri))
+        $user = User::staticGet('uri', $uri);
+        
+        if (!empty($user)) {
+            $profile = $user->getProfile();
+            return false;
+        }
+
+        // Now, check remotely
 
-        $oprofile = Ostatus_profile::staticGet('uri', $uri);
+        $oprofile = Ostatus_profile::ensureProfileURI($uri);
 
-        if (!empty($oprofile) && !$oprofile->isGroup()) {
+        if (!empty($oprofile)) {
             $profile = $oprofile->localProfile();
             return false;
         }
 
+        // Still not a hit, so give up.
+
         return true;
     }