2022-01-30 23:02:52 +00:00
|
|
|
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
|
|
|
|
use App\Helpers\ErrorHandler;
|
|
|
|
use App\Helpers\Misc;
|
|
|
|
use App\Helpers\RSS;
|
|
|
|
use App\Models\FeedTemplate;
|
|
|
|
|
|
|
|
class UserController {
|
|
|
|
static public function get(string $username) {
|
|
|
|
$cursor = Misc::getCursor();
|
|
|
|
$api = Misc::api();
|
|
|
|
$feed = $api->getUserFeed($username, $cursor);
|
|
|
|
if ($feed->meta->success) {
|
2022-02-16 14:20:35 +00:00
|
|
|
if ($feed->info->detail->user->privateAccount) {
|
2022-01-30 23:02:52 +00:00
|
|
|
http_response_code(400);
|
|
|
|
echo 'Private account detected! Not supported';
|
|
|
|
}
|
|
|
|
$latte = Misc::latte();
|
2022-02-16 14:20:35 +00:00
|
|
|
$latte->render(Misc::getView('user'), new FeedTemplate($feed->info->detail->user->nickname, $feed));
|
2022-01-30 23:02:52 +00:00
|
|
|
} else {
|
|
|
|
ErrorHandler::show($feed->meta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static public function rss(string $username) {
|
|
|
|
$api = Misc::api();
|
|
|
|
$feed = $api->getUserFeed($username);
|
|
|
|
if ($feed->meta->success) {
|
2022-02-16 14:20:35 +00:00
|
|
|
$feed = RSS::build('/@'.$username, $feed->info->detail->user->nickname, $feed->info->detail->user->signature, $feed->items);
|
2022-01-30 23:02:52 +00:00
|
|
|
// Setup headers
|
|
|
|
RSS::setHeaders('user.rss');
|
|
|
|
echo $feed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|