]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apitimelinegroup.php
Make other timeline API endpoints output Activity Streams JSON
[quix0rs-gnu-social.git] / actions / apitimelinegroup.php
index e1bc102e450edc54b2df4fe35b25887a89dac310..3fc930fa08664630a01972676875ba7888d5a466 100644 (file)
@@ -106,6 +106,11 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
 
         $self = $this->getSelfUri();
 
+        $link = common_local_url(
+            'ApiTimelineGroup',
+            array('nickname' => $this->group->nickname)
+        );
+
         switch($this->format) {
         case 'xml':
             $this->showXmlTimeline($this->notices);
@@ -123,24 +128,20 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
             break;
         case 'atom':
             header('Content-Type: application/atom+xml; charset=utf-8');
-
-            try {
                 $atom->addEntryFromNotices($this->notices);
                 $this->raw($atom->getString());
-            } catch (Atom10FeedException $e) {
-                $this->serverError(
-                    // TRANS: Server error displayed when generating an Atom feed fails.
-                    // TRANS: %s is the error.
-                    sprintf(_('Could not generate feed for group - %s'),$e->getMessage()),
-                   400,
-                   $this->format
-                );
-                return;
-            }
             break;
         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);
+            $this->raw($doc->asString());
+            break;
         default:
             $this->clientError(
                 // TRANS: Client error displayed when trying to handle an unknown API method.