X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FOStatus%2FOStatusPlugin.php;h=8e6e2d2891ace0722f28f57f64ef7875dd0759e8;hb=9ad00f726fff19caf5731eaf643b9910fef5e28f;hp=3cd29aff71fbcc08b38cfee803c7ff5be909a91b;hpb=f58008ebaff81cd8066c21b4a389de2fc9383259;p=quix0rs-gnu-social.git diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 3cd29aff71..8e6e2d2891 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -22,7 +22,9 @@ * @maintainer Brion Vibber */ -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', @@ -147,12 +145,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; } @@ -423,12 +419,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; } @@ -966,7 +962,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; } @@ -996,17 +992,69 @@ 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. + + $user = User::staticGet('uri', $uri); + + if (!empty($user)) { + $profile = $user->getProfile(); + return false; + } - // XXX: do discovery here instead (OStatus_profile::ensureProfileURI($uri)) + // 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; } + + 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; + } }