Move user xrd action to core and use hooks to extend

Moved the Webfinger user XRD action from the OStatus plugin to core.
Added hooks to add OStatus-specific stuff, but kept general stuff in
the core.
This commit is contained in:
Evan Prodromou
2010-11-26 21:38:38 -05:00
parent 3f3b38766f
commit 0a4911552e
5 changed files with 158 additions and 127 deletions

View File

@@ -1017,4 +1017,38 @@ class OStatusPlugin extends Plugin
'template' => $url,
'title' => array('Resource Descriptor'));
}
function onEndXrdActionLinks(&$xrd, $user)
{
// 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;
}
}