diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2024-10-29 20:19:46 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2024-10-29 21:36:21 +0100 |
commit | 5736b214b44bf34b3d2c0d6921c5044a6ad4378b (patch) | |
tree | 72c5ae2354fc1ebb93eff86e81876875e3277619 /main | |
parent | e51286039a0413cfbc456b0a9386c8ea369fdce3 (diff) |
Chatroom-specific identity
Changelog: Chatroom-specific identity
Diffstat (limited to 'main')
-rw-r--r-- | main/Main.hs | 8 | ||||
-rw-r--r-- | main/Test.hs | 11 |
2 files changed, 18 insertions, 1 deletions
diff --git a/main/Main.hs b/main/Main.hs index 32c226f..73def51 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -502,6 +502,7 @@ commands = , ("ice-send", cmdIceSend) #endif , ("join", cmdJoin) + , ("join-as", cmdJoinAs) , ("leave", cmdLeave) , ("members", cmdMembers) , ("select", cmdSelectContext) @@ -570,6 +571,13 @@ showPeer pidentity paddr = cmdJoin :: Command cmdJoin = joinChatroom =<< getSelectedChatroom +cmdJoinAs :: Command +cmdJoinAs = do + name <- asks ciLine + st <- getStorage + identity <- liftIO $ createIdentity st (Just $ T.pack name) Nothing + joinChatroomAs identity =<< getSelectedChatroom + cmdLeave :: Command cmdLeave = leaveChatroom =<< getSelectedChatroom diff --git a/main/Test.hs b/main/Test.hs index 741ffe8..1b156ae 100644 --- a/main/Test.hs +++ b/main/Test.hs @@ -290,6 +290,7 @@ commands = map (T.pack *** id) , ("chatroom-unsubscribe", cmdChatroomUnsubscribe) , ("chatroom-members", cmdChatroomMembers) , ("chatroom-join", cmdChatroomJoin) + , ("chatroom-join-as", cmdChatroomJoinAs) , ("chatroom-leave", cmdChatroomLeave) , ("chatroom-message-send", cmdChatroomMessageSend) ] @@ -757,7 +758,7 @@ cmdChatroomListLocal = do cmdChatroomWatchLocal :: Command cmdChatroomWatchLocal = do [] <- asks tiParams - h <- getHead + h <- getOrLoadHead out <- asks tiOutput void $ watchChatrooms h $ \_ -> \case Nothing -> return () @@ -815,6 +816,14 @@ cmdChatroomJoin = do joinChatroomByStateData =<< getChatroomStateData cid cmdOut "chatroom-join-done" +cmdChatroomJoinAs :: Command +cmdChatroomJoinAs = do + [ cid, name ] <- asks tiParams + st <- asks tiStorage + identity <- liftIO $ createIdentity st (Just name) Nothing + joinChatroomAsByStateData identity =<< getChatroomStateData cid + cmdOut $ unwords [ "chatroom-join-as-done", T.unpack cid ] + cmdChatroomLeave :: Command cmdChatroomLeave = do [ cid ] <- asks tiParams |