Compare commits

..

No commits in common. "1b8c913c5812258be55fcd2f25b792efeadd86f8" and "38ecd78db16061b3c4dd5814b586f281a56cb304" have entirely different histories.

9 changed files with 19 additions and 41 deletions

View file

@ -113,7 +113,7 @@ notifyUser user bev quant price master = do
"VERDAMMT NOCHMAL!!!" "VERDAMMT NOCHMAL!!!"
else else
return "" return ""
liftIO $ sendMail master email "Einkauf beim Matematen" liftIO $ sendMail email "Einkauf beim Matematen"
[lt| [lt|
Hallo #{userIdent user}, Hallo #{userIdent user},

View file

@ -191,7 +191,7 @@ checkAlert bId oldamount = do
master <- getYesod master <- getYesod
let tos = appEmail $ appSettings master let tos = appEmail $ appSettings master
mapM_ (\to -> mapM_ (\to ->
liftIO $ sendMail master to "Niedriger Bestand" liftIO $ sendMail to "Niedriger Bestand"
[stext| [stext|
Hallo, Hallo,
@ -204,18 +204,16 @@ Dein Matemat
|] |]
) tos ) tos
sendMail :: MonadIO m => App -> Text -> Text -> TL.Text -> m () sendMail :: MonadIO m => Text -> Text -> TL.Text -> m ()
sendMail master to subject body = liftIO $ do sendMail to subject body =
let sendmailLocation = appSendmailLocation $ appSettings master liftIO $ renderSendMail
fromMail = appFromMail $ appSettings master
renderSendMailCustom sendmailLocation []
Mail Mail
{ mailFrom = Address Nothing "noreply" { mailFrom = Address Nothing "noreply"
, mailTo = [Address Nothing to] , mailTo = [Address Nothing to]
, mailCc = [] , mailCc = []
, mailBcc = [] , mailBcc = []
, mailHeaders = [("Subject", subject), , mailHeaders = [("Subject", subject),
("List-Id", "\"Matemat\" <"<> (fromString fromMail) <>">")] ("List-Id", "\"Matemat\" <matemat@matemat.hq.c3d2.de>")]
, mailParts =[[Part , mailParts =[[Part
{ partType = "text/plain; charset=utf-8" { partType = "text/plain; charset=utf-8"
, partEncoding = None , partEncoding = None

View file

@ -119,8 +119,7 @@ postModifyUserR uId =
, UserAvatar =. userConfAvatar uc , UserAvatar =. userConfAvatar uc
, UserPin =. userConfPIN uc , UserPin =. userConfPIN uc
] ]
master <- getYesod liftIO $ notify user (userConfEmail uc)
liftIO $ notify user (userConfEmail uc) master
handleBarcodes (Left uId) (fromMaybe [] $ userConfBarcode uc) handleBarcodes (Left uId) (fromMaybe [] $ userConfBarcode uc)
setMessageI MsgUserEdited setMessageI MsgUserEdited
redirect $ SelectR uId redirect $ SelectR uId
@ -145,13 +144,12 @@ modifyUserForm user bs = UserConf
ents <- runDB $ selectList [] [Asc AvatarIdent] ents <- runDB $ selectList [] [Asc AvatarIdent]
optionsPairs $ map (\ent -> ((avatarIdent $ entityVal ent), entityKey ent)) ents optionsPairs $ map (\ent -> ((avatarIdent $ entityVal ent), entityKey ent)) ents
notify :: User -> Maybe Text -> App -> IO () notify :: User -> Maybe Text -> IO ()
notify user email master notify user email
| (userEmail user) == email = return () | (userEmail user) == email = return ()
| otherwise = case userEmail user of | otherwise = case userEmail user of
Just address -> Just address -> sendMail address "Profiländerung"
sendMail master address "Profiländerung" [stext|
[stext|
Hallo #{userIdent user}, Hallo #{userIdent user},
deine Profileinstellungen wurden geändert. deine Profileinstellungen wurden geändert.
@ -160,5 +158,5 @@ Nur damit du Bescheid weißt.
Grüße, Grüße,
der Matemat der Matemat
|] |]
Nothing -> return () Nothing -> return ()

View file

@ -76,7 +76,7 @@ transferForm = areq currencyField (bfs MsgValue) (Just 0)
notify :: User -> User -> Int -> App -> IO () notify :: User -> User -> Int -> App -> IO ()
notify sender rcpt amount master = do notify sender rcpt amount master = do
when (isJust $ userEmail sender) $ when (isJust $ userEmail sender) $
liftIO $ sendMail master (fromJust $ userEmail sender) "Guthabentransfer beim Matematen" liftIO $ sendMail (fromJust $ userEmail sender) "Guthabentransfer beim Matematen"
[stext| [stext|
Hallo #{userIdent sender} Hallo #{userIdent sender}
@ -87,7 +87,7 @@ Viele Grüße,
Dein Matemat Dein Matemat
|] |]
when (isJust $ userEmail rcpt) $ when (isJust $ userEmail rcpt) $
liftIO $ sendMail master (fromJust $ userEmail rcpt) "Guthabentransfer eingetroffen" liftIO $ sendMail (fromJust $ userEmail rcpt) "Guthabentransfer eingetroffen"
[stext| [stext|
Hallo #{userIdent rcpt} Hallo #{userIdent rcpt}

View file

@ -13,11 +13,6 @@
-- --
-- You should have received a copy of the GNU Affero General Public License -- You should have received a copy of the GNU Affero General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>. -- along with this program. If not, see <http://www.gnu.org/licenses/>.
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
module Model where module Model where
import ClassyPrelude.Yesod import ClassyPrelude.Yesod

View file

@ -80,10 +80,6 @@ data AppSettings = AppSettings
-- ^ Block user creation -- ^ Block user creation
, appAdminCreds :: Maybe Login , appAdminCreds :: Maybe Login
-- ^ optional admin credentials -- ^ optional admin credentials
, appSendmailLocation :: FilePath
-- ^ location of system's sendmail command
, appFromMail :: String
-- ^ Email address from which the yammat appears to send emails
} }
data Login = Login data Login = Login
@ -129,9 +125,6 @@ instance FromJSON AppSettings where
appAdminCreds <- o .:? "credentials" appAdminCreds <- o .:? "credentials"
appSendmailLocation <- o .: "sendmail-location"
appFromMail <- o .: "from-mail"
return AppSettings {..} return AppSettings {..}
-- | Settings for 'widgetFile', such as which template languages to support and -- | Settings for 'widgetFile', such as which template languages to support and

View file

@ -36,9 +36,6 @@ copyright_link: "https://github.com/nek0/yammat"
block_users: false block_users: false
sendmail-location: "/usr/sbin/sendmail"
from-mail: "matemat@matemat.hq.c3d2.de"
# optional administrative credentials. # optional administrative credentials.
# credentials: # credentials:
# login: "admin" # login: "admin"

View file

@ -16,9 +16,8 @@
checks = packages; checks = packages;
hydraJobs = hydraJobs = forSystems (system:
let let
system = builtins.head systems;
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
ghcVersions = ghcVersions =
builtins.filter (p: builtins.filter (p:
@ -28,12 +27,12 @@
builtins.foldl' (checks: ghcVersion: builtins.foldl' (checks: ghcVersion:
let let
haskellPackages = pkgs.haskell.packages.${ghcVersion}; haskellPackages = pkgs.haskell.packages.${ghcVersion};
inherit (pkgs.haskell.lib.compose) justStaticExecutables;
in in
checks // { checks // {
"${ghcVersion}".yammat = justStaticExecutables(haskellPackages.callPackage ./pkg.nix {}); "${ghcVersion}".yammat = haskellPackages.callPackage ./pkg.nix {};
} }
) {} ghcVersions; ) {} ghcVersions
);
devShell = forSystems (system: devShell = forSystems (system:
import ./shell.nix { import ./shell.nix {

View file

@ -1,5 +1,5 @@
name: yammat name: yammat
version: 0.0.9 version: 0.0.8
cabal-version: >= 1.8 cabal-version: >= 1.8
build-type: Simple build-type: Simple
license: AGPL-3 license: AGPL-3
@ -68,8 +68,6 @@ library
DerivingStrategies DerivingStrategies
StandaloneDeriving StandaloneDeriving
UndecidableInstances UndecidableInstances
DataKinds
FlexibleInstances
build-depends: base >= 4 && < 5 build-depends: base >= 4 && < 5
, yesod >= 1.6 , yesod >= 1.6