Merge branch 'notifier'

This commit is contained in:
Rene Vergara 2023-01-24 14:12:34 -06:00
commit a5f6c1efff
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2
11 changed files with 51 additions and 13 deletions

View file

@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.2.1] - 2023-01-24
### Added
- New configuration fields for SMTP
### Fixed
- Owner expiration query
- Xero token expiration query
## [1.2.0] - 2023-01-09 ## [1.2.0] - 2023-01-09
### Added ### Added

View file

@ -1,4 +1,4 @@
Copyright (c) 2022 Vergara Technologies LLC Copyright (c) 2023 Vergara Technologies LLC
======================================================= =======================================================
Bootstrap Open Source Licence ("BOSL") v. 1.0 Bootstrap Open Source Licence ("BOSL") v. 1.0

View file

@ -1,5 +1,5 @@
name: zgo-backend name: zgo-backend
version: 1.2.0 version: 1.2.1
git: "https://git.vergara.tech/Vergara_Tech/zgo-backend" git: "https://git.vergara.tech/Vergara_Tech/zgo-backend"
license: BOSL license: BOSL
author: "Rene Vergara" author: "Rene Vergara"
@ -58,6 +58,7 @@ library:
- blake3 - blake3
- memory - memory
- ghc-prim - ghc-prim
- network
executables: executables:
zgo-backend-exe: zgo-backend-exe:
@ -112,7 +113,6 @@ executables:
- warp-tls - warp-tls
- warp - warp
tests: tests:
zgo-backend-test: zgo-backend-test:
main: Spec.hs main: Spec.hs

View file

@ -6,6 +6,7 @@ import qualified Data.ByteString as BS
import Data.Configurator import Data.Configurator
import Data.SecureMem import Data.SecureMem
import qualified Data.Text as T import qualified Data.Text as T
import Network.Socket (PortNumber)
data Config = data Config =
Config Config
@ -21,6 +22,10 @@ data Config =
, c_useTls :: Bool , c_useTls :: Bool
, c_certificate :: String , c_certificate :: String
, c_key :: String , c_key :: String
, c_smtpHost :: String
, c_smtpPort :: Integer
, c_smtpUser :: String
, c_smtpPwd :: String
} }
deriving (Eq, Show) deriving (Eq, Show)
@ -39,6 +44,10 @@ loadZGoConfig path = do
useTls <- require config "tls" useTls <- require config "tls"
cert <- require config "certificate" cert <- require config "certificate"
key <- require config "key" key <- require config "key"
mailHost <- require config "smtpHost"
mailPort <- require config "smtpPort"
mailUser <- require config "smtpUser"
mailPwd <- require config "smtpPwd"
return $ return $
Config Config
dbHost dbHost
@ -53,3 +62,7 @@ loadZGoConfig path = do
useTls useTls
cert cert
key key
mailHost
mailPort
mailUser
mailPwd

View file

@ -292,3 +292,9 @@ findOwner zaddy = findOne (select ["address" =: zaddy] "owners")
findOwnerById :: T.Text -> Action IO (Maybe Document) findOwnerById :: T.Text -> Action IO (Maybe Document)
findOwnerById i = findOwnerById i =
findOne (select ["_id" =: (read (T.unpack i) :: ObjectId)] "owners") findOne (select ["_id" =: (read (T.unpack i) :: ObjectId)] "owners")
-- | Function to find Owners about to expire
findExpiringOwners :: UTCTime -> Action IO [Document]
findExpiringOwners now =
rest =<<
find (select ["expiration" =: ["$lte" =: addUTCTime 172800 now]] "owners")

View file

@ -283,8 +283,7 @@ findToken a = findOne (select ["address" =: a] "xerotokens")
findExpiringTokens :: UTCTime -> Action IO [Document] findExpiringTokens :: UTCTime -> Action IO [Document]
findExpiringTokens now = findExpiringTokens now =
rest =<< rest =<<
find find (select ["refExpires" =: ["$lte" =: addUTCTime 172800 now]] "xerotokens")
(select ["refExpires" =: ["$lte" =: addUTCTime 1728000 now]] "xerotokens")
-- | Function to request accesstoken -- | Function to request accesstoken
requestXeroToken :: Pipe -> T.Text -> Xero -> T.Text -> T.Text -> IO Bool requestXeroToken :: Pipe -> T.Text -> Xero -> T.Text -> T.Text -> IO Bool

View file

@ -17,7 +17,7 @@
# #
# resolver: ./custom-snapshot.yaml # resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-19.33 resolver: lts-20.8
#url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/4.yaml #url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/4.yaml
# User packages to be built. # User packages to be built.

View file

@ -24,7 +24,7 @@ packages:
hackage: blake3-0.2@sha256:d1146b9a51ccfbb0532780778b6d016a614e3d44c05d8c1923dde9a8be869045,2448 hackage: blake3-0.2@sha256:d1146b9a51ccfbb0532780778b6d016a614e3d44c05d8c1923dde9a8be869045,2448
snapshots: snapshots:
- completed: - completed:
sha256: 6d1532d40621957a25bad5195bfca7938e8a06d923c91bc52aa0f3c41181f2d4 sha256: bfafe5735ccb74527d754b1f9999ded72d7c3a6c3a88529449661431ccfbd6cc
size: 619204 size: 649327
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/33.yaml url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/8.yaml
original: lts-19.33 original: lts-20.8

View file

@ -5,9 +5,9 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
name: zgo-backend name: zgo-backend
version: 1.1.1 version: 1.2.1
synopsis: Haskell Back-end for the ZGo point-of-sale application synopsis: Haskell Back-end for the ZGo point-of-sale application
description: Please see the README on GitLab at <https://gitlab.com/pitmutt/zgo-backend#readme> description: Please see the README at <https://git.vergara.tech/Vergara_Tech//zgo-backend#readme>
category: Web category: Web
author: Rene Vergara author: Rene Vergara
maintainer: rene@vergara.network maintainer: rene@vergara.network
@ -22,7 +22,7 @@ extra-source-files:
source-repository head source-repository head
type: git type: git
location: https://gitlab.com/pitmutt/zgo-backend location: https://git.vergara.tech/Vergara_Tech/zgo-backend
library library
exposed-modules: exposed-modules:
@ -58,6 +58,7 @@ library
, jwt , jwt
, memory , memory
, mongoDB , mongoDB
, network
, quickcheck-instances , quickcheck-instances
, random , random
, regex-base , regex-base

View file

@ -10,3 +10,7 @@ port = 3000
tls = false tls = false
certificate = "/path/to/cert.pem" certificate = "/path/to/cert.pem"
key = "/path/to/key.pem" key = "/path/to/key.pem"
mailHost = "127.0.0.1"
mailPort = 1025
mailUser = "contact@zgo.cash"
mailPwd = "uib3K8BkCPexl_wr5bYfrg"

View file

@ -10,3 +10,7 @@ port = 3000
tls = false tls = false
certificate = "/path/to/cert.pem" certificate = "/path/to/cert.pem"
key = "/path/to/key.pem" key = "/path/to/key.pem"
mailHost = "127.0.0.1"
mailPort = 1025
mailUser = "contact@zgo.cash"
mailPwd = "uib3K8BkCPexl_wr5bYfrg"