]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/OStatusPlugin.php
Merge branch '0.9.x' into 1.0.x
[quix0rs-gnu-social.git] / plugins / OStatus / OStatusPlugin.php
index dcf1b36078d8f490d83d11b5e4c429df1b0a5d5d..f846a2fc8b94c46b6053afb39cb8ca60d36ff85b 100644 (file)
@@ -22,7 +22,9 @@
  * @maintainer Brion Vibber <brion@status.net>
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET')) {
+    exit(1);
+}
 
 set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/extlib/');
 
@@ -50,10 +52,6 @@ class OStatusPlugin extends Plugin
     function onRouterInitialized($m)
     {
         // Discovery actions
-        $m->connect('.well-known/host-meta',
-                    array('action' => 'hostmeta'));
-        $m->connect('main/xrd',
-                    array('action' => 'userxrd'));
         $m->connect('main/ownerxrd',
                     array('action' => 'ownerxrd'));
         $m->connect('main/ostatus',
@@ -655,7 +653,7 @@ class OStatusPlugin extends Plugin
             $act->title = _m("Join");
             // TRANS: Success message for subscribe to group attempt through OStatus.
             // TRANS: %1$s is the member name, %2$s is the subscribed group's name.
-            $act->content = sprintf(_m("%1$s has joined group %2$s."),
+            $act->content = sprintf(_m('%1$s has joined group %2$s.'),
                                     $member->getBestName(),
                                     $oprofile->getBestName());
 
@@ -707,7 +705,7 @@ class OStatusPlugin extends Plugin
             $act->title = _m("Leave");
             // TRANS: Success message for unsubscribe from group attempt through OStatus.
             // TRANS: %1$s is the member name, %2$s is the unsubscribed group's name.
-            $act->content = sprintf(_m("%1$s has left group %2$s."),
+            $act->content = sprintf(_m('%1$s has left group %2$s.'),
                                     $member->getBestName(),
                                     $oprofile->getBestName());
 
@@ -966,7 +964,7 @@ class OStatusPlugin extends Plugin
     {
         $group = User_group::staticGet('uri', $url);
         if ($group) {
-            $local = Local_group::staticGet('id', $group->id);
+            $local = Local_group::staticGet('group_id', $group->id);
             if ($local) {
                 return $group->id;
             }
@@ -1009,4 +1007,44 @@ class OStatusPlugin extends Plugin
 
         return true;
     }
+
+    function onEndXrdActionLinks(&$xrd, $user)
+    {
+       $xrd->links[] = array('rel' => Discovery::UPDATESFROM,
+                             'href' => common_local_url('ApiTimelineUser',
+                                                        array('id' => $user->id,
+                                                              'format' => 'atom')),
+                             'type' => 'application/atom+xml');
+       
+                   // Salmon
+        $salmon_url = common_local_url('usersalmon',
+                                       array('id' => $user->id));
+
+        $xrd->links[] = array('rel' => Salmon::REL_SALMON,
+                              'href' => $salmon_url);
+        // XXX : Deprecated - to be removed.
+        $xrd->links[] = array('rel' => Salmon::NS_REPLIES,
+                              'href' => $salmon_url);
+
+        $xrd->links[] = array('rel' => Salmon::NS_MENTIONS,
+                              'href' => $salmon_url);
+
+        // Get this user's keypair
+        $magickey = Magicsig::staticGet('user_id', $user->id);
+        if (!$magickey) {
+            // No keypair yet, let's generate one.
+            $magickey = new Magicsig();
+            $magickey->generate($user->id);
+        }
+
+        $xrd->links[] = array('rel' => Magicsig::PUBLICKEYREL,
+                              'href' => 'data:application/magic-public-key,'. $magickey->toString(false));
+
+        // TODO - finalize where the redirect should go on the publisher
+        $url = common_local_url('ostatussub') . '?profile={uri}';
+        $xrd->links[] = array('rel' => 'http://ostatus.org/schema/1.0/subscribe',
+                              'template' => $url );
+       
+       return true;
+    }
 }