Allow setting name when sending help request without account
This commit is contained in:
parent
77dcc02b9c
commit
1d69bd8d07
@ -245,7 +245,7 @@ instance RenderMessage UniWorX HelpIdentOptions where
|
|||||||
|
|
||||||
data HelpForm = HelpForm
|
data HelpForm = HelpForm
|
||||||
{ hfReferer:: Maybe Text
|
{ hfReferer:: Maybe Text
|
||||||
, hfUserId :: Either (Maybe Email) UserId
|
, hfUserId :: Either (Maybe Address) UserId
|
||||||
, hfRequest:: Text
|
, hfRequest:: Text
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,13 +256,13 @@ helpForm mReferer mUid = HelpForm
|
|||||||
<*> (unTextarea <$> areq textareaField (fslI MsgHelpRequest) Nothing)
|
<*> (unTextarea <$> areq textareaField (fslI MsgHelpRequest) Nothing)
|
||||||
<* submitButton
|
<* submitButton
|
||||||
where
|
where
|
||||||
identActions :: Map _ (AForm _ (Either (Maybe Email) UserId))
|
identActions :: Map _ (AForm _ (Either (Maybe Address) UserId))
|
||||||
identActions = Map.fromList $ case mUid of
|
identActions = Map.fromList $ case mUid of
|
||||||
(Just uid) -> (HIUser, pure $ Right uid):defaultActions
|
(Just uid) -> (HIUser, pure $ Right uid):defaultActions
|
||||||
Nothing -> defaultActions
|
Nothing -> defaultActions
|
||||||
|
|
||||||
defaultActions =
|
defaultActions =
|
||||||
[ (HIEmail, Left . Just <$> apreq emailField (fslI MsgEMail) Nothing)
|
[ (HIEmail, Left . Just <$> (Address <$> aopt textField (fslI MsgName) Nothing <*> apreq emailField (fslI MsgEMail) Nothing))
|
||||||
, (HIAnonymous, pure $ Left Nothing)
|
, (HIAnonymous, pure $ Left Nothing)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,8 @@ import Control.Monad.Morph as Import (MFunctor(..))
|
|||||||
|
|
||||||
import Control.Monad.Trans.Resource as Import (ReleaseKey)
|
import Control.Monad.Trans.Resource as Import (ReleaseKey)
|
||||||
|
|
||||||
|
import Network.Mail.Mime.Instances as Import ()
|
||||||
|
|
||||||
|
|
||||||
import Control.Monad.Trans.RWS (RWST)
|
import Control.Monad.Trans.RWS (RWST)
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import Utils.Lens
|
|||||||
import Data.Bitraversable
|
import Data.Bitraversable
|
||||||
|
|
||||||
|
|
||||||
dispatchJobHelpRequest :: Either (Maybe Email) UserId
|
dispatchJobHelpRequest :: Either (Maybe Address) UserId
|
||||||
-> UTCTime
|
-> UTCTime
|
||||||
-> Text -- ^ Help Request
|
-> Text -- ^ Help Request
|
||||||
-> Maybe Text -- ^ Referer
|
-> Maybe Text -- ^ Referer
|
||||||
@ -22,9 +22,10 @@ dispatchJobHelpRequest :: Either (Maybe Email) UserId
|
|||||||
dispatchJobHelpRequest jSender jRequestTime jHelpRequest jReferer = do
|
dispatchJobHelpRequest jSender jRequestTime jHelpRequest jReferer = do
|
||||||
supportAddress <- getsYesod $ appMailSupport . appSettings
|
supportAddress <- getsYesod $ appMailSupport . appSettings
|
||||||
userInfo <- bitraverse return (runDB . getEntity) jSender
|
userInfo <- bitraverse return (runDB . getEntity) jSender
|
||||||
let userAddress = either (fmap $ Address Nothing)
|
let userAddress = either
|
||||||
(fmap $ \(Entity _ User{..}) -> Address (Just userDisplayName) (CI.original userEmail))
|
id
|
||||||
userInfo
|
(fmap $ \(Entity _ User{..}) -> Address (Just userDisplayName) (CI.original userEmail))
|
||||||
|
userInfo
|
||||||
mailT def $ do
|
mailT def $ do
|
||||||
_mailTo .= [supportAddress]
|
_mailTo .= [supportAddress]
|
||||||
whenIsJust userAddress $ addMailHeader "Reply-To" . renderAddress
|
whenIsJust userAddress $ addMailHeader "Reply-To" . renderAddress
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import Data.List.NonEmpty (NonEmpty)
|
|||||||
data Job = JobSendNotification { jRecipient :: UserId, jNotification :: Notification }
|
data Job = JobSendNotification { jRecipient :: UserId, jNotification :: Notification }
|
||||||
| JobSendTestEmail { jEmail :: Email, jMailContext :: MailContext }
|
| JobSendTestEmail { jEmail :: Email, jMailContext :: MailContext }
|
||||||
| JobQueueNotification { jNotification :: Notification }
|
| JobQueueNotification { jNotification :: Notification }
|
||||||
| JobHelpRequest { jSender :: Either (Maybe Email) UserId
|
| JobHelpRequest { jSender :: Either (Maybe Address) UserId
|
||||||
, jRequestTime :: UTCTime
|
, jRequestTime :: UTCTime
|
||||||
, jHelpRequest :: Text, jReferer :: Maybe Text }
|
, jHelpRequest :: Text, jReferer :: Maybe Text }
|
||||||
| JobSetLogSettings { jInstance :: InstanceId, jLogSettings :: LogSettings }
|
| JobSetLogSettings { jInstance :: InstanceId, jLogSettings :: LogSettings }
|
||||||
|
|||||||
25
src/Network/Mail/Mime/Instances.hs
Normal file
25
src/Network/Mail/Mime/Instances.hs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||||
|
|
||||||
|
module Network.Mail.Mime.Instances
|
||||||
|
(
|
||||||
|
) where
|
||||||
|
|
||||||
|
import ClassyPrelude
|
||||||
|
import Network.Mail.Mime
|
||||||
|
import Data.Hashable (Hashable)
|
||||||
|
|
||||||
|
import Data.Aeson
|
||||||
|
import Data.Aeson.TH
|
||||||
|
|
||||||
|
import Utils.PathPiece
|
||||||
|
|
||||||
|
|
||||||
|
deriving instance Read Address
|
||||||
|
deriving instance Ord Address
|
||||||
|
deriving instance Generic Address
|
||||||
|
|
||||||
|
instance Hashable Address
|
||||||
|
|
||||||
|
deriveJSON defaultOptions
|
||||||
|
{ fieldLabelModifier = intercalate "-" . map toLower . drop 1 . splitCamel
|
||||||
|
} ''Address
|
||||||
@ -49,6 +49,7 @@ import qualified Network.HaskellNet.Auth as HaskellNet (UserName, Password, Auth
|
|||||||
import qualified Network.Socket as HaskellNet (PortNumber(..), HostName)
|
import qualified Network.Socket as HaskellNet (PortNumber(..), HostName)
|
||||||
|
|
||||||
import Network.Mail.Mime (Address)
|
import Network.Mail.Mime (Address)
|
||||||
|
import Network.Mail.Mime.Instances ()
|
||||||
|
|
||||||
import Mail (VerpMode)
|
import Mail (VerpMode)
|
||||||
|
|
||||||
@ -255,12 +256,6 @@ deriveFromJSON
|
|||||||
}
|
}
|
||||||
''SmtpAuthConf
|
''SmtpAuthConf
|
||||||
|
|
||||||
deriveFromJSON
|
|
||||||
defaultOptions
|
|
||||||
{ fieldLabelModifier = intercalate "-" . map toLower . drop 1 . splitCamel
|
|
||||||
}
|
|
||||||
''Address
|
|
||||||
|
|
||||||
|
|
||||||
instance FromJSON AppSettings where
|
instance FromJSON AppSettings where
|
||||||
parseJSON = withObject "AppSettings" $ \o -> do
|
parseJSON = withObject "AppSettings" $ \o -> do
|
||||||
|
|||||||
@ -6,9 +6,12 @@ $newline never
|
|||||||
<body>
|
<body>
|
||||||
<dl>
|
<dl>
|
||||||
$case userInfo
|
$case userInfo
|
||||||
$of Left (Just email)
|
$of Left (Just Address{..})
|
||||||
|
$maybe name <- addressName
|
||||||
|
<dt>Name
|
||||||
|
<dd>#{name}
|
||||||
<dt>E-Mail
|
<dt>E-Mail
|
||||||
<dd>#{email}
|
<dd>#{addressEmail}
|
||||||
$of Left Nothing
|
$of Left Nothing
|
||||||
$of Right Nothing
|
$of Right Nothing
|
||||||
<dt>Ungültige UserId erhalten!
|
<dt>Ungültige UserId erhalten!
|
||||||
|
|||||||
@ -30,6 +30,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-group--optional {
|
||||||
|
.form-group__label::after {
|
||||||
|
content: '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.form-group--submit .form-group__input {
|
.form-group--submit .form-group__input {
|
||||||
grid-column: 2;
|
grid-column: 2;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user