[CONTROLLER][PLUGIN][Reply] Move reply controller to it's plugin

This commit is contained in:
Hugo Sales 2021-12-01 01:31:02 +00:00 committed by Diogo Peralta Cordeiro
parent 73981030fa
commit 36613a826d
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 24 additions and 0 deletions

View File

@ -38,6 +38,7 @@ use App\Util\Common;
use App\Util\Exception\ClientException;
use App\Util\Exception\InvalidFormException;
use App\Util\Exception\NoSuchNoteException;
use App\Util\Exception\NotImplementedException;
use App\Util\Exception\RedirectException;
use App\Util\Form\FormFields;
use Component\Posting\Posting;
@ -138,4 +139,23 @@ class Reply extends Controller
'add_reply' => $form->createView(),
];
}
public function replies(Request $request)
{
// TODO replies
throw new NotImplementedException;
$actor_id = Common::ensureLoggedIn()->getId();
$notes = DB::dql('select n from App\Entity\Note n '
. 'where n.reply_to is not null and n.actor_id = :id '
. 'order by n.created DESC', ['id' => $actor_id], );
$notes_out = null;
Event::handle('FormatNoteList', [$notes, &$notes_out]);
return [
'_template' => 'feeds/feed.html.twig',
'notes' => $notes_out,
'page_title' => 'Replies feed',
];
}
}

View File

@ -134,6 +134,10 @@ class Reply extends NoteHandlerPlugin
public function onAddRoute($r)
{
$r->connect('reply_add', '/object/note/{id<\d+>}/reply', [ReplyController::class, 'replyAddNote']);
$r->connect('replies', '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/replies', [ReplyController::class, 'replies']);
return Event::next;
}
return Event::next;
}