Compare commits
No commits in common. "f5fc7b6cd197dc4ddf3c910cbd551866beb2971c" and "07b65584ff6a7f3ef750a01d4f915a3d08b17f18" have entirely different histories.
f5fc7b6cd1
...
07b65584ff
|
@ -5,12 +5,7 @@ declare(strict_types = 1);
|
|||
namespace Component\Collection\Util\Controller;
|
||||
|
||||
use App\Core\Controller;
|
||||
use Component\Feed\Feed;
|
||||
|
||||
class Collection extends Controller
|
||||
{
|
||||
public function query(string $query, ?string $language = null, ?Actor $actor = null)
|
||||
{
|
||||
return Feed::query($query, $this->int('page') ?? 1, $language, $actor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ use App\Util\Common;
|
|||
use App\Util\Exception\RedirectException;
|
||||
use Component\Collection\Util\Controller\FeedController;
|
||||
use Component\Conversation\Entity\ConversationMute;
|
||||
use Component\Feed\Feed;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
|
@ -46,7 +47,7 @@ class Conversation extends FeedController
|
|||
*/
|
||||
public function showConversation(Request $request, int $conversation_id)
|
||||
{
|
||||
$data = $this->query(query: "note-conversation:{$conversation_id}");
|
||||
$data = Feed::query(query: "note-conversation:{$conversation_id}", page: $this->int('p') ?? 1);
|
||||
$notes = $data['notes'];
|
||||
return [
|
||||
'_template' => 'collection/notes.html.twig',
|
||||
|
|
|
@ -59,8 +59,8 @@ class Reply extends FeedController
|
|||
}
|
||||
|
||||
$conversation_id = $note->getConversationId();
|
||||
$data = $this->query(query: "note-conversation:{$conversation_id}");
|
||||
$notes = $data['notes'];
|
||||
$data = Feed::query(query: "note-conversation:{$conversation_id}", page: $this->int('p') ?? 1);
|
||||
$notes = $data['notes'];
|
||||
return [
|
||||
'_template' => 'collection/notes.html.twig',
|
||||
'notes' => $notes,
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace Component\Feed\Controller;
|
|||
use function App\Core\I18n\_m;
|
||||
use App\Util\Common;
|
||||
use Component\Collection\Util\Controller\FeedController;
|
||||
use Component\Feed\Feed;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class Feeds extends FeedController
|
||||
|
@ -47,8 +48,9 @@ class Feeds extends FeedController
|
|||
*/
|
||||
public function public(Request $request): array
|
||||
{
|
||||
$data = $this->query(
|
||||
$data = Feed::query(
|
||||
query: 'note-local:true',
|
||||
page: $this->int('p'),
|
||||
language: Common::actor()?->getTopLanguage()?->getLocale(),
|
||||
);
|
||||
return [
|
||||
|
@ -65,8 +67,9 @@ class Feeds extends FeedController
|
|||
{
|
||||
$user = Common::ensureLoggedIn();
|
||||
$actor = $user->getActor();
|
||||
$data = $this->query(
|
||||
$data = Feed::query(
|
||||
query: 'note-from:subscribed-person,subscribed-group,subscribed-organization,subscribed-business',
|
||||
page: $this->int('p'),
|
||||
language: $actor->getTopLanguage()->getLocale(),
|
||||
actor: $actor,
|
||||
);
|
||||
|
|
|
@ -38,6 +38,7 @@ use App\Core\DB\DB;
|
|||
use function App\Core\I18n\_m;
|
||||
use App\Util\Common;
|
||||
use Component\Collection\Util\Controller\FeedController;
|
||||
use Component\Feed\Feed;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class Feeds extends FeedController
|
||||
|
@ -51,8 +52,9 @@ class Feeds extends FeedController
|
|||
public function network(Request $request): array
|
||||
{
|
||||
Common::ensureLoggedIn();
|
||||
$data = $this->query(
|
||||
$data = Feed::query(
|
||||
query: 'note-local:false',
|
||||
page: $this->int('p'),
|
||||
language: Common::actor()?->getTopLanguage()?->getLocale(),
|
||||
);
|
||||
return [
|
||||
|
@ -99,8 +101,9 @@ class Feeds extends FeedController
|
|||
public function federated(Request $request): array
|
||||
{
|
||||
Common::ensureLoggedIn();
|
||||
$data = $this->query(
|
||||
$data = Feed::query(
|
||||
query: '',
|
||||
page: $this->int('p'),
|
||||
language: Common::actor()?->getTopLanguage()?->getLocale(),
|
||||
);
|
||||
return [
|
||||
|
|
|
@ -31,6 +31,7 @@ use App\Util\Exception\RedirectException;
|
|||
use App\Util\Form\FormFields;
|
||||
use App\Util\Formatting;
|
||||
use Component\Collection\Util\Controller\FeedController;
|
||||
use Component\Feed\Feed;
|
||||
use Component\Search as Comp;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
@ -48,7 +49,7 @@ class Search extends FeedController
|
|||
$language = !\is_null($actor) ? $actor->getTopLanguage()->getLocale() : null;
|
||||
$q = $this->string('q');
|
||||
|
||||
$data = $this->query(query: $q, language: $language);
|
||||
$data = Feed::query(query: $q, page: $this->int('p'), language: $language);
|
||||
$notes = $data['notes'];
|
||||
$actors = $data['actors'];
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
|||
use Symfony\Component\HttpKernel\Event\ViewEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* @method ?int int(string $param)
|
||||
|
@ -243,21 +242,11 @@ abstract class Controller extends AbstractController implements EventSubscriberI
|
|||
{
|
||||
switch ($method) {
|
||||
case 'int':
|
||||
return !$this->request->query->has($args[0]) ? null : $this->request->query->getInt($args[0]);
|
||||
case 'bool':
|
||||
return !$this->request->query->has($args[0]) ? null : $this->request->query->getBoolean($args[0]);
|
||||
case 'string':
|
||||
if ($this->request->query->has($args[0])) {
|
||||
return match ($method) {
|
||||
'int' => $this->request->query->getInt($args[0]),
|
||||
'bool' => $this->request->query->getBoolean($args[0]),
|
||||
'string' => $this->request->query->get($args[0]),
|
||||
default => throw new BugFoundException('Inconsistent switch/match spotted'),
|
||||
};
|
||||
} elseif (\array_key_exists(1, $args) && $args[1] instanceof Throwable) {
|
||||
throw $args[1];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
return !$this->request->query->has($args[0]) ? null : $this->request->query->get($args[0]);
|
||||
case 'params':
|
||||
return $this->request->query->all();
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue