module Jobs.Handler.SendNotification.Utils
  ( mkEditNotifications
  ) where

import Import

import Text.Hamlet

import qualified Data.HashSet as HashSet


mkEditNotifications :: (MonadHandler m, HandlerSite m ~ UniWorX) => UserId -> m (HtmlUrlI18n UniWorXMessage (Route UniWorX))
mkEditNotifications uid = liftHandlerT $ do
  cID <- encrypt uid
  jwt <- encodeToken =<< bearerToken uid (Just . HashSet.singleton $ UserNotificationR cID) Nothing Nothing Nothing
  let
    editNotificationsUrl :: SomeRoute UniWorX
    editNotificationsUrl = SomeRoute (UserNotificationR cID, [(toPathPiece GetBearer, toPathPiece jwt)])
  editNotificationsUrl' <- toTextUrl editNotificationsUrl
  return ($(ihamletFile "templates/mail/editNotifications.hamlet") :: HtmlUrlI18n UniWorXMessage (Route UniWorX))
