case 'json':
$this->showJsonTimeline($this->notices);
break;
+ case 'as':
+ header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE);
+ $doc = new ActivityStreamJSONDocument($this->auth_user);
+ $doc->setTitle($atom->title);
+ $doc->addLink($link, 'alternate', 'text/html');
+ $doc->addItemsFromNotices($this->notices);
+
+ // XXX: Add paging extension?
+
+ $this->raw($doc->asString());
+ break;
default:
- // TRANS: Client error displayed when trying to handle an unknown API method.
+ // TRANS: Client error displayed when coming across a non-supported API method.
$this->clientError(_('API method not found.'), $code = 404);
break;
}
$this->clientError(_('Atom post must not be empty.'));
}
- $dom = DOMDocument::loadXML($xml);
- if (!$dom) {
+ $old = error_reporting(error_reporting() & ~(E_WARNING | E_NOTICE));
+ $dom = new DOMDocument();
+ $ok = $dom->loadXML($xml);
+ error_reporting($old);
+ if (!$ok) {
// TRANS: Client error displayed attempting to post an API that is not well-formed XML.
$this->clientError(_('Atom post must be well-formed XML.'));
}
$saved = null;
if (Event::handle('StartAtomPubNewActivity', array(&$activity, $this->user, &$saved))) {
-
if ($activity->verb != ActivityVerb::POST) {
// TRANS: Client error displayed when not using the POST verb. Do not translate POST.
$this->clientError(_('Can only handle POST activities.'));
if (!empty($notice)) {
// TRANS: Client error displayed when using another format than AtomPub.
+ // TRANS: %s is the notice URI.
$this->clientError(sprintf(_('Notice with URI "%s" already exists.'),
$note->id));
return;
} else {
$group = User_group::staticGet('uri', $uri);
if (!empty($group)) {
- $options['groups'][] = $uri;
+ $options['groups'][] = $group->id;
} else {
// @fixme: hook for discovery here
common_log(LOG_WARNING, sprintf('AtomPub post with unknown attention URI %s', $uri));