mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-26 18:25:49 +00:00
core: refactor terminal commands (#583)
This commit is contained in:
committed by
GitHub
parent
d9572cef86
commit
1df9a1ec2d
@@ -97,14 +97,14 @@ data ChatCommand
|
||||
| StartChat
|
||||
| SetFilesFolder FilePath
|
||||
| APIGetChats {pendingConnections :: Bool}
|
||||
| APIGetChat ChatType Int64 ChatPagination
|
||||
| APIGetChat ChatRef ChatPagination
|
||||
| APIGetChatItems Int
|
||||
| APISendMessage ChatType Int64 (Maybe FilePath) (Maybe ChatItemId) MsgContent
|
||||
| APISendMessageQuote ChatType Int64 ChatItemId MsgContent -- TODO discontinue
|
||||
| APIUpdateChatItem ChatType Int64 ChatItemId MsgContent
|
||||
| APIDeleteChatItem ChatType Int64 ChatItemId CIDeleteMode
|
||||
| APIChatRead ChatType Int64 (ChatItemId, ChatItemId)
|
||||
| APIDeleteChat ChatType Int64
|
||||
| APISendMessage ChatRef (Maybe FilePath) (Maybe ChatItemId) MsgContent
|
||||
| APISendMessageQuote ChatRef ChatItemId MsgContent -- TODO discontinue
|
||||
| APIUpdateChatItem ChatRef ChatItemId MsgContent
|
||||
| APIDeleteChatItem ChatRef ChatItemId CIDeleteMode
|
||||
| APIChatRead ChatRef (ChatItemId, ChatItemId)
|
||||
| APIDeleteChat ChatRef
|
||||
| APIAcceptContact Int64
|
||||
| APIRejectContact Int64
|
||||
| APIUpdateProfile Profile
|
||||
@@ -128,11 +128,11 @@ data ChatCommand
|
||||
| AddressAutoAccept Bool
|
||||
| AcceptContact ContactName
|
||||
| RejectContact ContactName
|
||||
| SendMessage ContactName ByteString
|
||||
| SendMessage ChatName ByteString
|
||||
| SendMessageQuote {contactName :: ContactName, msgDir :: AMsgDirection, quotedMsg :: ByteString, message :: ByteString}
|
||||
| SendMessageBroadcast ByteString
|
||||
| DeleteMessage ContactName ByteString
|
||||
| EditMessage {contactName :: ContactName, editedMsg :: ByteString, message :: ByteString}
|
||||
| DeleteMessage ChatName ByteString
|
||||
| EditMessage {chatName :: ChatName, editedMsg :: ByteString, message :: ByteString}
|
||||
| NewGroup GroupProfile
|
||||
| AddMember GroupName ContactName GroupMemberRole
|
||||
| JoinGroup GroupName
|
||||
@@ -142,10 +142,7 @@ data ChatCommand
|
||||
| DeleteGroup GroupName
|
||||
| ListMembers GroupName
|
||||
| ListGroups
|
||||
| SendGroupMessage GroupName ByteString
|
||||
| SendGroupMessageQuote {groupName :: GroupName, contactName_ :: Maybe ContactName, quotedMsg :: ByteString, message :: ByteString}
|
||||
| DeleteGroupMessage GroupName ByteString
|
||||
| EditGroupMessage {groupName :: ContactName, editedMsg :: ByteString, message :: ByteString}
|
||||
| LastMessages (Maybe ChatName) Int
|
||||
| SendFile ContactName FilePath
|
||||
| SendFileInv ContactName FilePath
|
||||
|
||||
@@ -44,6 +44,9 @@ data ChatType = CTDirect | CTGroup | CTContactRequest | CTContactConnection
|
||||
data ChatName = ChatName ChatType Text
|
||||
deriving (Show)
|
||||
|
||||
data ChatRef = ChatRef ChatType Int64
|
||||
deriving (Show)
|
||||
|
||||
instance ToJSON ChatType where
|
||||
toJSON = J.genericToJSON . enumJSON $ dropPrefix "CT"
|
||||
toEncoding = J.genericToEncoding . enumJSON $ dropPrefix "CT"
|
||||
|
||||
@@ -45,7 +45,6 @@ runInputLoop ct cc = forever $ do
|
||||
echo s = printToTerminal ct [plain s]
|
||||
isMessage = \case
|
||||
Right SendMessage {} -> True
|
||||
Right SendGroupMessage {} -> True
|
||||
Right SendFile {} -> True
|
||||
Right SendFileInv {} -> True
|
||||
Right SendGroupFile {} -> True
|
||||
@@ -139,7 +138,6 @@ updateTermState ac tw (key, ms) ts@TerminalState {inputString = s, inputPosition
|
||||
Left _ -> inp
|
||||
Right cmd -> case cmd of
|
||||
SendMessage {} -> "! " <> inp
|
||||
SendGroupMessage {} -> "! " <> inp
|
||||
SendMessageQuote {contactName, message} -> T.unpack $ "! @" <> contactName <> " " <> safeDecodeUtf8 message
|
||||
SendGroupMessageQuote {groupName, message} -> T.unpack $ "! #" <> groupName <> " " <> safeDecodeUtf8 message
|
||||
_ -> inp
|
||||
|
||||
Reference in New Issue
Block a user