X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FFeed.php;h=b9d573979a721430eec0467b725635c5b0efb8b7;hb=8b02c285472ea28002cf9c8924e2885dd207ccd8;hp=eabd45da23eef073fef2af295390a2b3bdd4fa0a;hpb=07cb88788540b4da83fbbaca2eed12bb6bed3a35;p=friendica.git diff --git a/src/Module/Feed.php b/src/Module/Feed.php index eabd45da23..b9d573979a 100644 --- a/src/Module/Feed.php +++ b/src/Module/Feed.php @@ -1,10 +1,31 @@ . + * + */ namespace Friendica\Module; use Friendica\BaseModule; use Friendica\Core\System; -use Friendica\Protocol\OStatus; +use Friendica\Model\User; +use Friendica\Network\HTTPException; +use Friendica\Protocol\Feed as ProtocolFeed; /** * Provides public Atom feeds @@ -16,32 +37,14 @@ use Friendica\Protocol\OStatus; * - /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() + protected function rawContent(array $request = []) { - $a = self::getApp(); - - $last_update = defaults($_GET, 'last_update', ''); - $nocache = !empty($_GET['nocache']) && local_user(); - - // @TODO: Replace with parameter from router - if ($a->argc < 2) { - System::httpExit(400); - } - - $type = null; - // @TODO: Replace with parameter from router - if ($a->argc > 2) { - $type = $a->argv[2]; - } - + $nick = $this->parameters['nickname'] ?? ''; + $type = $this->parameters['type'] ?? null; switch ($type) { case 'posts': case 'comments': @@ -55,10 +58,19 @@ class Feed extends BaseModule $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(); + $last_update = $this->getRequestValue($request, 'last_update', ''); + + $owner = User::getOwnerDataByNick($nick); + if (!$owner || $owner['account_expired'] || $owner['account_removed']) { + throw new HTTPException\NotFoundException($this->t('User not found.')); + } + + if ($owner['blocked']) { + throw new HTTPException\UnauthorizedException($this->t('Access to this profile has been restricted.')); + } + + $feed = ProtocolFeed::atom($owner, $last_update, 10, $type); + + $this->httpExit($feed, Response::TYPE_ATOM); } }