1111module Simplex.Messaging.Notifications.Server.Main where
1212
1313import Control.Logger.Simple (setLogLevel )
14- import Control.Monad ( (<$!>) , unless , void )
14+ import Control.Monad (unless , void , (<$!>) )
1515import qualified Data.ByteString.Char8 as B
1616import Data.Functor (($>) )
1717import Data.Ini (lookupValue , readIniFile )
@@ -31,9 +31,10 @@ import Simplex.Messaging.Client (HostMode (..), NetworkConfig (..), ProtocolClie
3131import Simplex.Messaging.Client.Agent (SMPClientAgentConfig (.. ), defaultSMPClientAgentConfig )
3232import qualified Simplex.Messaging.Crypto as C
3333import Simplex.Messaging.Notifications.Protocol (NtfTokenId )
34- import Simplex.Messaging.Notifications.Server (runNtfServer , restoreServerLastNtfs )
34+ import Simplex.Messaging.Notifications.Server (restoreServerLastNtfs , runNtfServer )
3535import Simplex.Messaging.Notifications.Server.Env (NtfServerConfig (.. ), defaultInactiveClientExpiration )
3636import Simplex.Messaging.Notifications.Server.Push.APNS (defaultAPNSPushClientConfig )
37+ import Simplex.Messaging.Notifications.Server.Push.WebPush (VapidKey (.. ), WebPushConfig (.. ), mkVapid )
3738import Simplex.Messaging.Notifications.Server.Store (newNtfSTMStore )
3839import Simplex.Messaging.Notifications.Server.Store.Postgres (exportNtfDbStore , importNtfSTMStore , newNtfDbStore )
3940import Simplex.Messaging.Notifications.Server.StoreLog (readWriteNtfSTMStore )
@@ -55,9 +56,8 @@ import System.Directory (createDirectoryIfMissing, doesFileExist, renameFile)
5556import System.Exit (exitFailure )
5657import System.FilePath (combine )
5758import System.IO (BufferMode (.. ), hSetBuffering , stderr , stdout )
58- import Text.Read (readMaybe )
5959import System.Process (readCreateProcess , shell )
60- import Simplex.Messaging.Notifications.Server.Push.WebPush ( WebPushConfig ( .. ), VapidKey , mkVapid )
60+ import Text.Read ( readMaybe )
6161
6262ntfServerCLI :: FilePath -> FilePath -> IO ()
6363ntfServerCLI cfgPath logPath =
@@ -215,12 +215,13 @@ ntfServerCLI cfgPath logPath =
215215 hSetBuffering stdout LineBuffering
216216 hSetBuffering stderr LineBuffering
217217 fp <- checkSavedFingerprint cfgPath defaultX509Config
218- vapidKey <- getVapidKey vapidKeyPath
218+ vapidKey@ VapidKey {fp = vapidFp} <- getVapidKey vapidKeyPath
219219 let host = either (const " <hostnames>" ) T. unpack $ lookupValue " TRANSPORT" " host" ini
220220 port = T. unpack $ strictIni " TRANSPORT" " port" ini
221221 cfg@ NtfServerConfig {transports} = serverConfig vapidKey
222222 srv = ProtoServerWithAuth (NtfServer [THDomainName host] (if port == " 443" then " " else port) (C. KeyHash fp)) Nothing
223223 printServiceInfo serverVersion srv
224+ B. putStrLn $ " VAPID: " <> vapidFp
224225 printNtfServerConfig transports dbStoreConfig
225226 runNtfServer cfg
226227 where
@@ -360,18 +361,21 @@ cliCommandP cfgPath logPath iniFile =
360361 skipTokensP =
361362 option
362363 strParse
363- ( long " skip-tokens"
364- <> help " Skip tokens during import"
365- <> value S. empty
366- )
364+ ( long " skip-tokens"
365+ <> help " Skip tokens during import"
366+ <> value S. empty
367+ )
367368 initP :: Parser InitOptions
368369 initP = do
369370 enableStoreLog <-
370- flag' False
371+ flag'
372+ False
371373 ( long " disable-store-log"
372374 <> help " Disable store log for persistence (enabled by default)"
373375 )
374- <|> flag True True
376+ <|> flag
377+ True
378+ True
375379 ( long " store-log"
376380 <> short ' l'
377381 <> help " Enable store log for persistence (DEPRECATED, enabled by default)"
0 commit comments