fix: update watchlist calendar

This commit is contained in:
Maël Gangloff 2024-08-02 01:06:49 +02:00
parent 7a46299dd4
commit 4e13fa1464
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
2 changed files with 4 additions and 6 deletions

View File

@ -64,7 +64,7 @@ export interface User {
roles: string[] roles: string[]
} }
export interface Watchlist { export interface Watchlist {
domains: string[], domains: string[],
triggers: { event: EventAction, action: TriggerAction }[], triggers: { event: EventAction, action: TriggerAction }[],
connector?: string connector?: string
@ -76,8 +76,8 @@ export async function request<T = any, R = AxiosResponse<T>, D = any>(config: Ax
baseURL: '/api', baseURL: '/api',
withCredentials: true, withCredentials: true,
headers: { headers: {
Accept: 'application/ld+json',
...config.headers, ...config.headers,
Accept: 'application/ld+json'
} }
} }
return await axios.request<T, R, D>(axiosConfig) return await axios.request<T, R, D>(axiosConfig)

View File

@ -25,7 +25,6 @@ use Sabre\VObject\Reader;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
@ -67,6 +66,7 @@ class WatchListController extends AbstractController
* @throws ParseException * @throws ParseException
* @throws EofException * @throws EofException
* @throws InvalidDataException * @throws InvalidDataException
* @throws Exception
*/ */
#[Route( #[Route(
path: '/api/watchlists/{token}/calendar', path: '/api/watchlists/{token}/calendar',
@ -78,10 +78,8 @@ class WatchListController extends AbstractController
)] )]
public function getWatchlistCalendar(string $token): Response public function getWatchlistCalendar(string $token): Response
{ {
/** @var WatchList $watchList */
$watchList = $this->watchListRepository->findOneBy(["token" => $token]); $watchList = $this->watchListRepository->findOneBy(["token" => $token]);
/** @var User $user */
$user = $this->getUser();
if (!$user->getWatchLists()->contains($watchList)) throw new UnauthorizedHttpException('');
$calendar = new Calendar(); $calendar = new Calendar();