/** * Receives a notification. * * @param \Drupal\feeds\FeedInterface $feeds_feed * The feed to perform the request on. * @param \Symfony\Component\HttpFoundation\Request $request * The request object. * * @return Symfony\Component\HttpFoundation\Response * The response object. * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * Thrown if the subscription was not found or the request parameters were * invalid. */ public function receive(FeedInterface $feeds_feed, Request $request) { if (!($sig = $request->headers->get('X-Hub-Signature'))) { throw new NotFoundHttpException(); } $result = array(); parse_str($sig, $result); if (empty($result['sha1'])) { throw new NotFoundHttpException(); } if (!($sub = $this->subscriptionCrud->getSubscription($feeds_feed->id()))) { throw new NotFoundHttpException(); } $raw = file_get_contents('php://input'); if ($result['sha1'] !== hash_hmac('sha1', $raw, $sub['secret'])) { throw new NotFoundHttpException(); } try { $feeds_feed->importRaw($raw); } catch (InterfaceNotImplementedException $e) { // The fetcher does not support PuSH updates. throw new NotFoundHttpException(); } return new Response('', 200); }