diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2019-11-17 21:53:00 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2019-11-17 21:58:03 +0100 |
commit | dd4c6aeae1cf30035f3c7c3d52e58082f6b7aa36 (patch) | |
tree | ea5602baed328c7d69e35763c3b32b1615669e18 /src/Main.hs | |
parent | 372436c0d1abee281f6c957059c7043daa742ea8 (diff) |
Announce periodically and on local identity changes
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Main.hs b/src/Main.hs index 6bd0967..5ce9f86 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -75,16 +75,15 @@ main = do interactiveLoop :: Storage -> String -> IO () interactiveLoop st bhost = runInputT defaultSettings $ do erebosHead <- liftIO $ loadLocalState st - let serebos = wrappedLoad (headRef erebosHead) :: Stored LocalState - Just self = verifyIdentity $ lsIdentity $ fromStored serebos - outputStrLn $ T.unpack $ displayIdentity self + outputStrLn $ T.unpack $ maybe (error "failed to verify local identity") displayIdentity $ + verifyIdentity $ lsIdentity $ fromStored $ wrappedLoad $ headRef erebosHead haveTerminalUI >>= \case True -> return () False -> error "Requires terminal" extPrint <- getExternalPrint let extPrintLn str = extPrint $ str ++ "\n"; chanPeer <- liftIO $ - startServer extPrintLn bhost self + startServer erebosHead extPrintLn bhost [ (T.pack "attach", SomeService (emptyServiceState :: AttachService)) , (T.pack "dmsg", SomeService (emptyServiceState :: DirectMessageService)) ] @@ -123,8 +122,10 @@ interactiveLoop st bhost = runInputT defaultSettings $ do then (cmdSetPeer $ read scmd, args) else (fromMaybe (cmdUnknown scmd) $ lookup scmd commands, args) _ -> (cmdSend, input) + curHead <- liftIO $ loadLocalState st res <- liftIO $ runExceptT $ flip execStateT cstate $ runReaderT cmd CommandInput - { ciSelf = self + { ciSelf = fromMaybe (error "failed to verify local identity") $ + verifyIdentity $ lsIdentity $ fromStored $ wrappedLoad $ headRef curHead , ciLine = line , ciPrint = extPrintLn , ciPeers = liftIO $ readMVar peers |