We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 43a67b15 authored by Evan Prodromou's avatar Evan Prodromou

show a single notice in atom entry format

parent 69a1ecec
...@@ -105,8 +105,8 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction ...@@ -105,8 +105,8 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
{ {
parent::handle($args); parent::handle($args);
if (!in_array($this->format, array('xml', 'json'))) { if (!in_array($this->format, array('xml', 'json', 'atom'))) {
$this->clientError(_('API method not found.'), $code = 404); $this->clientError(_('API method not found.'), 404);
return; return;
} }
...@@ -122,10 +122,18 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction ...@@ -122,10 +122,18 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
function showNotice() function showNotice()
{ {
if (!empty($this->notice)) { if (!empty($this->notice)) {
if ($this->format == 'xml') { switch ($this->format) {
case 'xml':
$this->showSingleXmlStatus($this->notice); $this->showSingleXmlStatus($this->notice);
} elseif ($this->format == 'json') { break;
case 'json':
$this->show_single_json_status($this->notice); $this->show_single_json_status($this->notice);
break;
case 'atom':
$this->showSingleAtomStatus($this->notice);
break;
default:
throw new Exception(sprintf(_("Unsupported format: %s"), $this->format));
} }
} else { } else {
......
...@@ -726,6 +726,12 @@ class ApiAction extends Action ...@@ -726,6 +726,12 @@ class ApiAction extends Action
$this->endDocument('xml'); $this->endDocument('xml');
} }
function showSingleAtomStatus($notice)
{
header('Content-Type: application/atom+xml; charset=utf-8');
print $notice->asAtomEntry(true, true, true, $this->auth_user);
}
function show_single_json_status($notice) function show_single_json_status($notice)
{ {
$this->initDocument('json'); $this->initDocument('json');
......
...@@ -399,12 +399,12 @@ class Router ...@@ -399,12 +399,12 @@ class Router
$m->connect('api/statuses/show.:format', $m->connect('api/statuses/show.:format',
array('action' => 'ApiStatusesShow', array('action' => 'ApiStatusesShow',
'format' => '(xml|json)')); 'format' => '(xml|json|atom)'));
$m->connect('api/statuses/show/:id.:format', $m->connect('api/statuses/show/:id.:format',
array('action' => 'ApiStatusesShow', array('action' => 'ApiStatusesShow',
'id' => '[0-9]+', 'id' => '[0-9]+',
'format' => '(xml|json)')); 'format' => '(xml|json|atom)'));
$m->connect('api/statuses/update.:format', $m->connect('api/statuses/update.:format',
array('action' => 'ApiStatusesUpdate', array('action' => 'ApiStatusesUpdate',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment