From a168d79d757c28cd328b9c9cd0fb5033c57a4ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 23 Mar 2024 13:27:46 +0100 Subject: Chatroom shared type --- main/Test.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'main/Test.hs') diff --git a/main/Test.hs b/main/Test.hs index 991cf85..182d941 100644 --- a/main/Test.hs +++ b/main/Test.hs @@ -29,6 +29,7 @@ import System.IO import System.IO.Error import Erebos.Attach +import Erebos.Chatroom import Erebos.Contact import Erebos.Identity import Erebos.Message @@ -264,6 +265,8 @@ commands = map (T.pack *** id) , ("dm-send-contact", cmdDmSendContact) , ("dm-list-peer", cmdDmListPeer) , ("dm-list-contact", cmdDmListContact) + , ("chatroom-create", cmdChatroomCreate) + , ("chatroom-list-local", cmdChatroomListLocal) ] cmdStore :: Command @@ -565,3 +568,23 @@ cmdDmListContact = do [cid] <- asks tiParams Just to <- contactIdentity <$> getContact cid dmList to + +cmdChatroomCreate :: Command +cmdChatroomCreate = do + [name] <- asks tiParams + void $ createChatroom (Just name) Nothing + +cmdChatroomListLocal :: Command +cmdChatroomListLocal = do + [] <- asks tiParams + h <- getHead + let rooms = fromSetBy (comparing $ roomName <=< roomStateRoom) . lookupSharedValue . lsShared . headObject $ h + forM_ rooms $ \room -> do + r:_ <- return $ filterAncestors $ concatMap storedRoots $ toComponents room + cmdOut $ concat + [ "chatroom-list-item " + , show $ refDigest $ storedRef r + , " " + , maybe "" T.unpack $ roomName =<< roomStateRoom room + ] + cmdOut "chatroom-list-done" -- cgit v1.2.3