X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=actions%2Fapitimelineuser.php;h=b0681c191a5d9f6949d02843ee48aa5276d9e054;hb=c97048d01bea468e0cf8865b60c3c250b4515c39;hp=b3b908accc8a3f971df137c98632820ccf78b026;hpb=47f31bce47b182aa55c02c7872d7e473d3ab10f2;p=quix0rs-gnu-social.git diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php index b3b908accc..b0681c191a 100644 --- a/actions/apitimelineuser.php +++ b/actions/apitimelineuser.php @@ -201,8 +201,19 @@ class ApiTimelineUserAction extends ApiBareAuthAction case 'json': $this->showJsonTimeline($this->notices); break; + case 'as': + header('Content-Type: application/json; charset=utf-8'); + $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; } @@ -311,8 +322,11 @@ class ApiTimelineUserAction extends ApiBareAuthAction $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.')); } @@ -329,7 +343,6 @@ class ApiTimelineUserAction extends ApiBareAuthAction $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.')); @@ -405,6 +418,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction 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;