-<?php\r
-\r
-namespace Friendica\Module;\r
-\r
-use Friendica\BaseModule;\r
-use Friendica\Protocol\OStatus;\r
-use Friendica\Util\Network;\r
-\r
-/**\r
- * Provides public Atom feeds\r
- *\r
- * Currently supported:\r
- * - /feed/[nickname]/ => posts\r
- * - /feed/[nickname]/posts => posts\r
- * - /feed/[nickname]/comments => comments\r
- * - /feed/[nickname]/replies => comments\r
- * - /feed/[nickname]/activity => activity\r
- *\r
- * The nocache GET parameter is provided mainly for debug purposes, requires auth\r
- *\r
- * @brief Provides public Atom feeds\r
- *\r
- * @author Hypolite Petovan <mrpetovan@gmail.com>\r
- */\r
-class Feed extends BaseModule\r
-{\r
- public static function content()\r
- {\r
- $a = self::getApp();\r
-\r
- $last_update = x($_GET, 'last_update') ? $_GET['last_update'] : '';\r
- $nocache = x($_GET, 'nocache') && local_user();\r
-\r
- if ($a->argc < 2) {\r
- Network::httpStatusExit(400);\r
- }\r
-\r
- $type = null;\r
- if ($a->argc > 2) {\r
- $type = $a->argv[2];\r
- }\r
-\r
- switch ($type) {\r
- case 'posts':\r
- case 'comments':\r
- case 'activity':\r
- break;\r
- case 'replies':\r
- $type = 'comments';\r
- break;\r
- default:\r
- $type = 'posts';\r
- }\r
-\r
- $nickname = $a->argv[1];\r
- header("Content-type: application/atom+xml");\r
- echo OStatus::feed($nickname, $last_update, 10, $type, $nocache);\r
- killme();\r
- }\r
-}\r
+<?php
+/**
+ * @copyright Copyright (C) 2010-2022, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\DI;
+use Friendica\Protocol\Feed as ProtocolFeed;
+
+/**
+ * Provides public Atom feeds
+ *
+ * Currently supported:
+ * - /feed/[nickname]/ => posts
+ * - /feed/[nickname]/posts => posts
+ * - /feed/[nickname]/comments => comments
+ * - /feed/[nickname]/replies => comments
+ * - /feed/[nickname]/activity => activity
+ *
+ * The nocache GET parameter is provided mainly for debug purposes, requires auth
+ *
+ * @author Hypolite Petovan <hypolite@mrpetovan.com>
+ */
+class Feed extends BaseModule
+{
+ protected function content(array $request = []): string
+ {
+ $a = DI::app();
+
+ $last_update = $_GET['last_update'] ?? '';
+ $nocache = !empty($_GET['nocache']) && local_user();
+
+ $type = null;
+ // @TODO: Replace with parameter from router
+ if (DI::args()->getArgc() > 2) {
+ $type = DI::args()->getArgv()[2];
+ }
+
+ switch ($type) {
+ case 'posts':
+ case 'comments':
+ case 'activity':
+ // Correct type names, no change needed
+ break;
+ case 'replies':
+ $type = 'comments';
+ break;
+ default:
+ $type = 'posts';
+ }
+
+ header("Content-type: application/atom+xml; charset=utf-8");
+ echo ProtocolFeed::atom($this->parameters['nickname'], $last_update, 10, $type, $nocache, true);
+ exit();
+ }
+}