let implementations build channel strings for realtime

This commit is contained in:
Evan Prodromou 2009-07-15 15:30:33 -04:00
parent 420980f0e0
commit 8b1ac4ea20

View File

@ -61,16 +61,16 @@ class RealtimePlugin extends Plugin
function onEndShowScripts($action) function onEndShowScripts($action)
{ {
$timeline = null; $path = null;
switch ($action->trimmed('action')) { switch ($action->trimmed('action')) {
case 'public': case 'public':
$timeline = 'timelines-public'; $path = array('public');
break; break;
case 'tag': case 'tag':
$tag = $action->trimmed('tag'); $tag = $action->trimmed('tag');
if (!empty($tag)) { if (!empty($tag)) {
$timeline = 'timelines-tag-'.$tag; $path = array('tag', $tag);
} else { } else {
return true; return true;
} }
@ -79,6 +79,8 @@ class RealtimePlugin extends Plugin
return true; return true;
} }
$timeline = $this->_pathToChannel($path);
$scripts = $this->_getScripts(); $scripts = $this->_getScripts();
foreach ($scripts as $script) { foreach ($scripts as $script) {
@ -106,30 +108,31 @@ class RealtimePlugin extends Plugin
function onEndNoticeSave($notice) function onEndNoticeSave($notice)
{ {
$timelines = array(); $paths = array();
// XXX: Add other timelines; this is just for the public one // XXX: Add other timelines; this is just for the public one
if ($notice->is_local || if ($notice->is_local ||
($notice->is_local == 0 && !common_config('public', 'localonly'))) { ($notice->is_local == 0 && !common_config('public', 'localonly'))) {
$timelines[] = 'timelines-public'; $paths[] = array('public');
} }
$tags = $this->getNoticeTags($notice); $tags = $this->getNoticeTags($notice);
if (!empty($tags)) { if (!empty($tags)) {
foreach ($tags as $tag) { foreach ($tags as $tag) {
$timelines[] = 'timelines-tag-' . $tag; $paths[] = array('tag', $tag);
} }
} }
if (count($timelines) > 0) { if (count($paths) > 0) {
$json = $this->noticeAsJson($notice); $json = $this->noticeAsJson($notice);
$this->_connect(); $this->_connect();
foreach ($timelines as $timeline) { foreach ($paths as $path) {
$timeline = $this->_pathToChannel($path);
$this->_publish($timeline, $json); $this->_publish($timeline, $json);
} }
@ -218,4 +221,9 @@ class RealtimePlugin extends Plugin
function _disconnect() function _disconnect()
{ {
} }
function _pathToChannel($path)
{
return '';
}
} }