From 413247d344aaabe38f42ca22b4355ad77cf67c06 Mon Sep 17 00:00:00 2001 From: rainydaysavings Date: Fri, 4 Sep 2020 00:15:18 +0100 Subject: [PATCH] [CONTROLLER] Replies and network queries implemented --- src/Controller/Network.php | 58 ++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/Controller/Network.php b/src/Controller/Network.php index a273399973..16a6d70a23 100644 --- a/src/Controller/Network.php +++ b/src/Controller/Network.php @@ -24,6 +24,7 @@ * @category Controller * * @author Hugo Sales + * @author Eliseu Amaro * @copyright 2020 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ @@ -32,6 +33,7 @@ namespace App\Controller; use App\Core\Controller; use App\Core\DB\DB; +use App\Util\Common; use Symfony\Component\HttpFoundation\Request; class Network extends Controller @@ -47,35 +49,37 @@ class Network extends Controller public function home(Request $request) { - $notes = DB::dql( - 'select n from ( - ( - select note.id - from App\Entity\Note - inner join App\Entity\Follow - with note.id = follow.followed - ) - union all - ( - select note.id - from App\Entity\Note - with note.id = note.reply_to - ) - union all - ( - select note.id - from App\Entity\Note - inner join App\Entity\GroupInbox - with note.id = group_inbox.activity_id - inner join App\Entity\GroupMember - where group_inbox.group_id = group_member.group_id - ) - ) n ' . - 'order by n.created DESC' - ); return [ '_template' => 'network/public.html.twig', - 'notes' => $notes, + 'notes' => DB::dql('select n, g_inbox, g_member ' . + 'from App\Entity\Note n inner join App\Entity\GroupInbox g_inbox inner join App\Entity\GroupMember g_member ' . + 'with n.id = g_inbox.activity_id ' . + 'order by n.created DESC' + ), + ]; + } + + public function network(Request $request) + { + return [ + '_template' => 'network/public.html.twig', + 'notes' => DB::dql('select n from App\Entity\Note n ' . + 'where n.scope = 1 ' . + 'order by n.created DESC' + ), + ]; + } + + public function replies(Request $request) + { + $actor_id = Common::ensureLoggedIn()->getActor()->getId(); + + return [ + '_template' => 'network/public.html.twig', + 'notes' => DB::dql('select n from App\Entity\Note n ' . + 'where n.reply_to is not null and n.gsactor_id = ' . $actor_id . + 'order by n.created DESC' + ), ]; } }