function stopWatchingFromEmail($userid, $code, Request $request, Application $app)
 {
     $userRepo = new UserAccountRepository();
     $user = $userRepo->loadByID($userid);
     if (!$user) {
         $app['monolog']->addError("Failed stop watching site from email - user not known");
         die("NO");
         // TODO
     }
     $userWatchesSiteStopRepo = new UserWatchesSiteStopRepository();
     $userWatchesSiteStop = $userWatchesSiteStopRepo->loadByUserAccountIDAndSiteIDAndAccessKey($user->getId(), $app['currentSite']->getId(), $code);
     if (!$userWatchesSiteStop) {
         $app['monolog']->addError("Failed stop watching site from email - user " . $user->getId() . " - code wrong");
         die("NO");
         // TODO
     }
     $userWatchesSiteRepo = new UserWatchesSiteRepository();
     $userWatchesSite = $userWatchesSiteRepo->loadByUserAndSite($user, $app['currentSite']);
     if (!$userWatchesSite || !$userWatchesSite->getIsWatching()) {
         $app['monolog']->addError("Failed stop watching site from email - user " . $user->getId() . " - not watching");
         die("You don't watch this site");
         // TODO
     }
     if ($request->request->get('action') == 'unwatch' && $request->request->get('CSFRToken') == $app['websession']->getCSFRToken()) {
         $userWatchesSiteRepo->stopUserWatchingSite($user, $app['currentSite']);
         // redirect here because if we didn't the twig global and $app vars would be wrong (the old state)
         // this is an easy way to get round that.
         $app['flashmessages']->addMessage("You have stopped watching this.");
         return $app->redirect('/');
     }
     return $app['twig']->render('site/index/stopWatchingFromEmail.html.twig', array('user' => $user));
 }