messageBus = $messageBus; } /** * @Route("/public/incoming-hook/calendar/msgraph/events/{userId}", name="chill_calendar_remote_msgraph_incoming_webhook_events", * methods={"POST"}) */ public function webhookCalendarReceiver(int $userId, Request $request): Response { if ($request->query->has('validationToken')) { return new Response($request->query->get('validationToken'), Response::HTTP_OK, [ 'content-type' => 'text/plain', ]); } try { $body = json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) { throw new BadRequestHttpException('could not decode json', $e); } $this->messageBus->dispatch(new MSGraphChangeNotificationMessage($body, $userId)); return new Response('', Response::HTTP_ACCEPTED); } }