Compare commits

...

5 Commits

Author SHA1 Message Date
nek0 1b8c913c58 version bump 2022-06-18 21:28:48 +02:00
nek0 d67f517e04 make cofnigurable sendmail and from-email 2022-06-18 21:28:39 +02:00
sand20 e7069228a8 Strip ghc from final build 2022-06-16 22:45:49 +02:00
Astro 63191180a5 yammat.cabal: add extensions DataKinds, FlexibleInstances
Reason:
> Model.hs:25:1: error:
>     Generating Persistent entities now requires the following language extensions:
>
> DataKinds
> FlexibleInstances
2021-03-17 15:20:51 +01:00
Astro 29a34b4759 flake.nix: remove ${system} from hydraJobs schema 2021-03-12 02:24:30 +01:00
9 changed files with 41 additions and 19 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -13,6 +13,11 @@
--
-- 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/>.
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
module Model where
import ClassyPrelude.Yesod

View File

@ -80,6 +80,10 @@ data AppSettings = AppSettings
-- ^ Block user creation
, appAdminCreds :: Maybe Login
-- ^ 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
@ -125,6 +129,9 @@ instance FromJSON AppSettings where
appAdminCreds <- o .:? "credentials"
appSendmailLocation <- o .: "sendmail-location"
appFromMail <- o .: "from-mail"
return AppSettings {..}
-- | Settings for 'widgetFile', such as which template languages to support and

View File

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

View File

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

View File

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