X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FFeed.php;h=49ecfed96c166cd6d6676f77816ec1a100e77e43;hb=b543ee8ac78168328c7a7f2d725ee01bb333e941;hp=efc5a097e827c3b77e8133fdb2773a58d7c38b37;hpb=cd3643d17485aa1000c41312f5b363788e755c49;p=friendica.git diff --git a/src/Module/Feed.php b/src/Module/Feed.php index efc5a097e8..49ecfed96c 100644 --- a/src/Module/Feed.php +++ b/src/Module/Feed.php @@ -1,60 +1,63 @@ - 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 - * - * @brief Provides public Atom feeds - * - * @author Hypolite Petovan - */ -class Feed extends BaseModule -{ - public static function content() - { - $a = self::getApp(); - - $last_update = x($_GET, 'last_update') ? $_GET['last_update'] : ''; - $nocache = x($_GET, 'nocache') && local_user(); - - if ($a->argc < 2) { - Network::httpStatusExit(400); - } - - $type = null; - if ($a->argc > 2) { - $type = $a->argv[2]; - } - - switch ($type) { - case 'posts': - case 'comments': - case 'activity': - break; - case 'replies': - $type = 'comments'; - break; - default: - $type = 'posts'; - } - - $nickname = $a->argv[1]; - header("Content-type: application/atom+xml"); - echo OStatus::feed($nickname, $last_update, 10, $type, $nocache); - killme(); - } -} + 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 + * + * @brief Provides public Atom feeds + * + * @author Hypolite Petovan + */ +class Feed extends BaseModule +{ + public static function content() + { + $a = self::getApp(); + + $last_update = $_GET['last_update'] ?? ''; + $nocache = !empty($_GET['nocache']) && local_user(); + + // @TODO: Replace with parameter from router + if ($a->argc < 2) { + throw new \Friendica\Network\HTTPException\BadRequestException(); + } + + $type = null; + // @TODO: Replace with parameter from router + if ($a->argc > 2) { + $type = $a->argv[2]; + } + + switch ($type) { + case 'posts': + case 'comments': + case 'activity': + // Correct type names, no change needed + break; + case 'replies': + $type = 'comments'; + break; + default: + $type = 'posts'; + } + + // @TODO: Replace with parameter from router + $nickname = $a->argv[1]; + header("Content-type: application/atom+xml; charset=utf-8"); + echo OStatus::feed($nickname, $last_update, 10, $type, $nocache, true); + exit(); + } +}