OStatus: fix salmon link on Atom feeds; add a url spec for group feeds as well (endpoint needs impl)

This commit is contained in:
Brion Vibber 2010-02-11 20:02:17 +00:00
parent 20714d1f35
commit 21bfbc43ad

View File

@ -80,6 +80,9 @@ class OStatusPlugin extends Plugin
$m->connect('main/salmon/user/:id', $m->connect('main/salmon/user/:id',
array('action' => 'salmon'), array('action' => 'salmon'),
array('id' => '[0-9]+')); array('id' => '[0-9]+'));
$m->connect('main/salmon/group/:id',
array('action' => 'salmongroup'),
array('id' => '[0-9]+'));
return true; return true;
} }
@ -111,25 +114,31 @@ class OStatusPlugin extends Plugin
*/ */
function onStartApiAtom(Action $action) function onStartApiAtom(Action $action)
{ {
if ($action instanceof ApiTimelineUserAction || $action instanceof ApiTimelineGroupAction) { if ($action instanceof ApiTimelineUserAction) {
$id = $action->arg('id'); $salmonAction = 'salmon';
if (strval(intval($id)) === strval($id)) { } else if ($action instanceof ApiTimelineGroupAction) {
// Canonical form of id in URL? These are used for OStatus syndication. $salmonAction = 'salmongroup';
} else {
$hub = common_config('ostatus', 'hub'); return;
if (empty($hub)) { }
// Updates will be handled through our internal PuSH hub.
$hub = common_local_url('pushhub'); $id = $action->arg('id');
} if (strval(intval($id)) === strval($id)) {
$action->element('link', array('rel' => 'hub', // Canonical form of id in URL? These are used for OStatus syndication.
'href' => $hub));
$hub = common_config('ostatus', 'hub');
// Also, we'll add in the salmon link if (empty($hub)) {
$action->element('link', array('rel' => 'salmon', // Updates will be handled through our internal PuSH hub.
'href' => common_local_url('salmon'))); $hub = common_local_url('pushhub');
} }
$action->element('link', array('rel' => 'hub',
'href' => $hub));
// Also, we'll add in the salmon link
$salmon = common_local_url($salmonAction, array('id' => $id));
$action->element('link', array('rel' => 'salmon',
'href' => $salmon));
} }
return true;
} }
/** /**
@ -191,14 +200,17 @@ class OStatusPlugin extends Plugin
array('nickname' => $profile->nickname)); array('nickname' => $profile->nickname));
$output->element('a', array('href' => $url, $output->element('a', array('href' => $url,
'class' => 'entity_remote_subscribe'), 'class' => 'entity_remote_subscribe'),
_('OStatus')); _m('OStatus'));
$output->elementEnd('li'); $output->elementEnd('li');
} }
} }
/** /**
* Check if we've got some Salmon stuff to send * Check if we've got remote replies to send via Salmon.
*
* @fixme push webfinger lookup & sending to a background queue
* @fixme also detect short-form name for remote subscribees where not ambiguous
*/ */
function onEndNoticeSave($notice) function onEndNoticeSave($notice)
{ {
@ -234,7 +246,6 @@ class OStatusPlugin extends Plugin
} }
} }
/** /**
* Garbage collect unused feeds on unsubscribe * Garbage collect unused feeds on unsubscribe
*/ */
@ -253,7 +264,9 @@ class OStatusPlugin extends Plugin
return true; return true;
} }
/**
* Make sure necessary tables are filled out.
*/
function onCheckSchema() { function onCheckSchema() {
$schema = Schema::get(); $schema = Schema::get();
$schema->ensureTable('feedinfo', Feedinfo::schemaDef()); $schema->ensureTable('feedinfo', Feedinfo::schemaDef());