From 1e4e9158993be8585d17564eaee9538f1dee989a Mon Sep 17 00:00:00 2001 From: nek0 Date: Mon, 15 Feb 2021 19:00:29 +0100 Subject: [PATCH] draft out user notification --- TODO.md | 4 ++-- src/Control/Buy.hs | 4 +++- src/Control/User.hs | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/TODO.md b/TODO.md index b166798..5dfd930 100644 --- a/TODO.md +++ b/TODO.md @@ -5,8 +5,8 @@ ### Required - [ ] E-Mail notification -- [ ] Security mechanism has to be triggered, if present -- [ ] Buy products in stock +- [x] Security mechanism has to be triggered, if present +- [x] Buy products in stock ### Optional diff --git a/src/Control/Buy.hs b/src/Control/Buy.hs index e611a35..b752f0a 100644 --- a/src/Control/Buy.hs +++ b/src/Control/Buy.hs @@ -43,12 +43,14 @@ buy auth pds = do void $ addToUserBalance auid (-price) conn newBalance <- userBalanceSelect conn auid userUpdateTimestamp auth - return $ PurchaseResult + let result = PurchaseResult ( if newBalance < 0 then PurchaseDebtful else PurchaseOK ) missing + userNotify auth result + return result Nothing -> do void $ insertNewJournalEntry (JournalSubmit diff --git a/src/Control/User.hs b/src/Control/User.hs index 41f4d84..07ae63f 100644 --- a/src/Control/User.hs +++ b/src/Control/User.hs @@ -142,3 +142,11 @@ userTransfer Nothing _ = throwError $ err401 { errBody = "No Authentication present." } + +userNotify + :: Maybe (Int, AuthMethod) + -> [PurchaseDetail] + -> PurchaseResult + -> MateHandler () +userNotify (Just (auid, method)) boughtItems (PruchaseResult flag missing) = do +