. // }}} /** * Handle network public feed * * @package GNUsocial * @category Controller * * @author Hugo Sales * @author Eliseu Amaro * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ namespace App\Controller; use App\Core\Controller\FeedController; use App\Core\DB\DB; use function App\Core\I18n\_m; use App\Core\VisibilityScope; use App\Entity\Note; use App\Util\Exception\ClientException; use App\Util\Exception\NotFoundException; use Symfony\Component\HttpFoundation\Request; class Feeds extends FeedController { // Can't have constants inside herestring private $public_scope = VisibilityScope::PUBLIC; private $instance_scope = VisibilityScope::PUBLIC | VisibilityScope::SITE; private $message_scope = VisibilityScope::MESSAGE; private $subscriber_scope = VisibilityScope::PUBLIC | VisibilityScope::SUBSCRIBER; public function public(Request $request) { $notes = Note::getAllNotes($this->instance_scope); return $this->process_feed([ '_template' => 'feeds/feed.html.twig', 'page_title' => 'Public feed', 'notes' => $notes, ]); } public function home(Request $request, string $nickname) { try { $target = DB::findOneBy('actor', ['nickname' => $nickname, 'is_local' => true]); } catch (NotFoundException) { throw new ClientException(_m('User {nickname} doesn\'t exist', ['{nickname}' => $nickname])); } // TODO Handle replies in home stream $query = << {$this->message_scope} order by note.modified DESC END; $notes = DB::sql($query, ['target_actor_id' => $target->getId()]); return $this->process_feed([ '_template' => 'feeds/feed.html.twig', 'page_title' => 'Home feed', 'notes' => $notes, ]); } public function network(Request $request) { $notes = Note::getAllNotes($this->public_scope); return $this->process_feed([ '_template' => 'feeds/feed.html.twig', 'page_title' => 'Network feed', 'notes' => $notes, ]); } }