X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FFeed.php;h=6d291198dcd09627e6fa60e984350c22ef38bc1b;hb=a8402109b183e81dad4e5443883dd292df094b86;hp=4c7059c038dc0bb221699f4c3840dcad3606f2bf;hpb=5e60fa8210b502797209de770780d6d7ba81b86c;p=friendica.git diff --git a/src/Module/Feed.php b/src/Module/Feed.php index 4c7059c038..6d291198dc 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,34 +37,19 @@ 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(); - - if ($a->argc < 2) { - System::httpExit(400); - } - - $type = null; - if ($a->argc > 2) { - $type = $a->argv[2]; - } - + $nick = $this->parameters['nickname'] ?? ''; + $type = $this->parameters['type'] ?? null; switch ($type) { case 'posts': case 'comments': case 'activity': + // Correct type names, no change needed break; case 'replies': $type = 'comments'; @@ -52,9 +58,19 @@ class Feed extends BaseModule $type = 'posts'; } - $nickname = $a->argv[1]; - header("Content-type: application/atom+xml"); - echo OStatus::feed($nickname, $last_update, 10, $type, $nocache, true); - killme(); + $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); + + System::httpExit($feed, Response::TYPE_ATOM); } }