diff --git a/apps/simplex-broadcast-bot/Options.hs b/apps/simplex-broadcast-bot/Options.hs index e6c20a427..0c69845f0 100644 --- a/apps/simplex-broadcast-bot/Options.hs +++ b/apps/simplex-broadcast-bot/Options.hs @@ -105,5 +105,6 @@ mkChatOpts BroadcastBotOpts {coreOptions} = chatServerPort = Nothing, optFilesFolder = Nothing, allowInstantFiles = True, + muteNotifications = True, maintenance = False } diff --git a/src/Simplex/Chat/Mobile.hs b/src/Simplex/Chat/Mobile.hs index ae8e3241b..03f7f60e2 100644 --- a/src/Simplex/Chat/Mobile.hs +++ b/src/Simplex/Chat/Mobile.hs @@ -129,6 +129,7 @@ mobileChatOpts dbFilePrefix dbKey = chatServerPort = Nothing, optFilesFolder = Nothing, allowInstantFiles = True, + muteNotifications = True, maintenance = True } diff --git a/src/Simplex/Chat/Options.hs b/src/Simplex/Chat/Options.hs index b9dc2e363..af4009b78 100644 --- a/src/Simplex/Chat/Options.hs +++ b/src/Simplex/Chat/Options.hs @@ -36,6 +36,7 @@ data ChatOpts = ChatOpts chatServerPort :: Maybe String, optFilesFolder :: Maybe FilePath, allowInstantFiles :: Bool, + muteNotifications :: Bool, maintenance :: Bool } @@ -221,6 +222,11 @@ chatOptsP appDir defaultDbFileName = do <> short 'f' <> help "Send and receive instant files without acceptance" ) + muteNotifications <- + switch + ( long "mute" + <> help "Mute notifications" + ) maintenance <- switch ( long "maintenance" @@ -235,6 +241,7 @@ chatOptsP appDir defaultDbFileName = do chatServerPort, optFilesFolder, allowInstantFiles, + muteNotifications, maintenance } diff --git a/src/Simplex/Chat/Terminal.hs b/src/Simplex/Chat/Terminal.hs index fa79e48e7..6a148e877 100644 --- a/src/Simplex/Chat/Terminal.hs +++ b/src/Simplex/Chat/Terminal.hs @@ -41,8 +41,8 @@ terminalChatConfig = simplexChatTerminal :: WithTerminal t => ChatConfig -> ChatOpts -> t -> IO () simplexChatTerminal cfg opts t = do - sendToast <- initializeNotifications - handle checkDBKeyError . simplexChatCore cfg opts (Just sendToast) $ \u cc -> do + sendToast <- if muteNotifications opts then pure Nothing else Just <$> initializeNotifications + handle checkDBKeyError . simplexChatCore cfg opts sendToast $ \u cc -> do ct <- newChatTerminal t when (firstTime cc) . printToTerminal ct $ chatWelcome u runChatTerminal ct cc diff --git a/tests/ChatClient.hs b/tests/ChatClient.hs index eb15e3f0e..097f6aed8 100644 --- a/tests/ChatClient.hs +++ b/tests/ChatClient.hs @@ -73,6 +73,7 @@ testOpts = chatServerPort = Nothing, optFilesFolder = Nothing, allowInstantFiles = True, + muteNotifications = True, maintenance = False }