forked from GNUsocial/gnu-social
[COMPONENT][LeftPanel] Ensure given url corresponds to a feed
This commit is contained in:
parent
dbc8bf2ae1
commit
682f9aa611
@ -25,12 +25,14 @@ namespace Component\LeftPanel\Controller;
|
|||||||
|
|
||||||
use App\Core\Cache;
|
use App\Core\Cache;
|
||||||
use App\Core\Controller;
|
use App\Core\Controller;
|
||||||
|
use App\Core\Controller\FeedController;
|
||||||
use App\Core\DB\DB;
|
use App\Core\DB\DB;
|
||||||
use App\Core\Form;
|
use App\Core\Form;
|
||||||
use function App\Core\I18n\_m;
|
use function App\Core\I18n\_m;
|
||||||
use App\Core\Router\Router;
|
use App\Core\Router\Router;
|
||||||
use App\Entity\Feed;
|
use App\Entity\Feed;
|
||||||
use App\Util\Common;
|
use App\Util\Common;
|
||||||
|
use App\Util\Exception\ClientException;
|
||||||
use App\Util\Exception\RedirectException;
|
use App\Util\Exception\RedirectException;
|
||||||
use Functional as F;
|
use Functional as F;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||||
@ -141,6 +143,10 @@ class EditFeeds extends Controller
|
|||||||
try {
|
try {
|
||||||
$match = Router::match($data['url']);
|
$match = Router::match($data['url']);
|
||||||
$route = $match['_route'];
|
$route = $match['_route'];
|
||||||
|
$controller = $match['_controller'];
|
||||||
|
if (!is_subclass_of($controller, FeedController::class)) {
|
||||||
|
throw new ClientException(_m('The page with url "{url}" is not a valid feed', ['{url}' => $data['url']]));
|
||||||
|
}
|
||||||
DB::persist(Feed::create([
|
DB::persist(Feed::create([
|
||||||
'actor_id' => $user->getId(),
|
'actor_id' => $user->getId(),
|
||||||
'url' => $data['url'],
|
'url' => $data['url'],
|
||||||
@ -152,9 +158,7 @@ class EditFeeds extends Controller
|
|||||||
Cache::delete($key);
|
Cache::delete($key);
|
||||||
throw new RedirectException();
|
throw new RedirectException();
|
||||||
} catch (ResourceNotFoundException) {
|
} catch (ResourceNotFoundException) {
|
||||||
// TODO add error (flash?)
|
throw new ClientException(_m('Invalid route with url "{url}"', ['{url}' => $data['url']]), code: 404);
|
||||||
// throw new ClientException(_m('Invalid route'));
|
|
||||||
// continue bellow
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user