X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FOStatus%2FOStatusPlugin.php;h=26b7ade64dbf2203525f35880aaa4040b55e0025;hb=a74eda4e9ad344ba965c111567bd285266a95e23;hp=4ab2023cbee77d6d48212aed41aa306279c39e09;hpb=53d45d7ffbe6bcdf336a0e666942557c11cf909b;p=quix0rs-gnu-social.git diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 4ab2023cbe..26b7ade64d 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -52,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', @@ -115,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'); } @@ -149,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; } @@ -234,7 +230,7 @@ class OStatusPlugin extends Plugin return false; } - function onStartGroupSubscribe($output, $group) + function onStartGroupSubscribe($widget, $group) { $cur = common_current_user(); @@ -242,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')); @@ -425,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; } @@ -681,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 */ @@ -998,17 +994,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; + } }