mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-07-11 20:38:55 +00:00
message and continuation type
This commit is contained in:
@@ -432,6 +432,7 @@ data ChatMsgEvent (e :: MsgEncoding) where
|
||||
XMember :: {profile :: Profile, newMemberId :: MemberId, newMemberKey :: MemberKey} -> ChatMsgEvent 'Json
|
||||
XDirectDel :: ChatMsgEvent 'Json
|
||||
XGrpInv :: GroupInvitation -> ChatMsgEvent 'Json
|
||||
XGrpInvPub :: PublicGroupInvitation -> ChatMsgEvent 'Json
|
||||
XGrpAcpt :: MemberId -> ChatMsgEvent 'Json
|
||||
XGrpLinkInv :: GroupLinkInvitation -> ChatMsgEvent 'Json
|
||||
XGrpLinkReject :: GroupLinkRejection -> ChatMsgEvent 'Json
|
||||
@@ -965,6 +966,7 @@ data CMEventTag (e :: MsgEncoding) where
|
||||
XMember_ :: CMEventTag 'Json
|
||||
XDirectDel_ :: CMEventTag 'Json
|
||||
XGrpInv_ :: CMEventTag 'Json
|
||||
XGrpInvPub_ :: CMEventTag 'Json
|
||||
XGrpAcpt_ :: CMEventTag 'Json
|
||||
XGrpLinkInv_ :: CMEventTag 'Json
|
||||
XGrpLinkReject_ :: CMEventTag 'Json
|
||||
@@ -1022,6 +1024,7 @@ instance MsgEncodingI e => StrEncoding (CMEventTag e) where
|
||||
XMember_ -> "x.member"
|
||||
XDirectDel_ -> "x.direct.del"
|
||||
XGrpInv_ -> "x.grp.inv"
|
||||
XGrpInvPub_ -> "x.grp.inv.pub"
|
||||
XGrpAcpt_ -> "x.grp.acpt"
|
||||
XGrpLinkInv_ -> "x.grp.link.inv"
|
||||
XGrpLinkReject_ -> "x.grp.link.reject"
|
||||
@@ -1080,6 +1083,7 @@ instance StrEncoding ACMEventTag where
|
||||
"x.member" -> XMember_
|
||||
"x.direct.del" -> XDirectDel_
|
||||
"x.grp.inv" -> XGrpInv_
|
||||
"x.grp.inv.pub" -> XGrpInvPub_
|
||||
"x.grp.acpt" -> XGrpAcpt_
|
||||
"x.grp.link.inv" -> XGrpLinkInv_
|
||||
"x.grp.link.reject" -> XGrpLinkReject_
|
||||
@@ -1134,6 +1138,7 @@ toCMEventTag msg = case msg of
|
||||
XMember {} -> XMember_
|
||||
XDirectDel -> XDirectDel_
|
||||
XGrpInv _ -> XGrpInv_
|
||||
XGrpInvPub _ -> XGrpInvPub_
|
||||
XGrpAcpt _ -> XGrpAcpt_
|
||||
XGrpLinkInv _ -> XGrpLinkInv_
|
||||
XGrpLinkReject _ -> XGrpLinkReject_
|
||||
@@ -1192,6 +1197,7 @@ hasNotification = \case
|
||||
XFile_ -> True
|
||||
XContact_ -> True
|
||||
XGrpInv_ -> True
|
||||
XGrpInvPub_ -> True
|
||||
XGrpMemFwd_ -> True
|
||||
XGrpDel_ -> True
|
||||
XCallInv_ -> True
|
||||
@@ -1201,6 +1207,7 @@ hasDeliveryReceipt :: CMEventTag e -> Bool
|
||||
hasDeliveryReceipt = \case
|
||||
XMsgNew_ -> True
|
||||
XGrpInv_ -> True
|
||||
XGrpInvPub_ -> True
|
||||
XCallInv_ -> True
|
||||
_ -> False
|
||||
|
||||
@@ -1287,6 +1294,7 @@ appJsonToCM AppMessageJson {v, msgId, event, params} = do
|
||||
XMember_ -> XMember <$> p "profile" <*> p "newMemberId" <*> p "newMemberKey"
|
||||
XDirectDel_ -> pure XDirectDel
|
||||
XGrpInv_ -> XGrpInv <$> p "groupInvitation"
|
||||
XGrpInvPub_ -> XGrpInvPub <$> p "groupInvitation"
|
||||
XGrpAcpt_ -> XGrpAcpt <$> p "memberId"
|
||||
XGrpLinkInv_ -> XGrpLinkInv <$> p "groupLinkInvitation"
|
||||
XGrpLinkReject_ -> XGrpLinkReject <$> p "groupLinkRejection"
|
||||
@@ -1358,6 +1366,7 @@ chatToAppMessage chatMsg@ChatMessage {chatVRange, msgId, chatMsgEvent} = case en
|
||||
XMember {profile, newMemberId, newMemberKey} -> o ["profile" .= profile, "newMemberId" .= newMemberId, "newMemberKey" .= newMemberKey]
|
||||
XDirectDel -> JM.empty
|
||||
XGrpInv groupInv -> o ["groupInvitation" .= groupInv]
|
||||
XGrpInvPub groupInv -> o ["groupInvitation" .= groupInv]
|
||||
XGrpAcpt memId -> o ["memberId" .= memId]
|
||||
XGrpLinkInv groupLinkInv -> o ["groupLinkInvitation" .= groupLinkInv]
|
||||
XGrpLinkReject groupLinkRjct -> o ["groupLinkRejection" .= groupLinkRjct]
|
||||
|
||||
@@ -1900,6 +1900,7 @@ data CommandFunction
|
||||
| CFSetShortLink
|
||||
| CFGetRelayDataJoin
|
||||
| CFGetRelayDataAccept
|
||||
| CFGetGroupDataInv
|
||||
deriving (Eq, Show)
|
||||
|
||||
instance FromField CommandFunction where fromField = fromTextField_ textDecode
|
||||
@@ -1920,6 +1921,7 @@ instance TextEncoding CommandFunction where
|
||||
"set_short_link" -> Just CFSetShortLink
|
||||
"get_relay_data_join" -> Just CFGetRelayDataJoin
|
||||
"get_relay_data_accept" -> Just CFGetRelayDataAccept
|
||||
"get_group_data_inv" -> Just CFGetGroupDataInv
|
||||
_ -> Nothing
|
||||
textEncode = \case
|
||||
CFCreateConnGrpMemInv -> "create_conn"
|
||||
@@ -1934,6 +1936,7 @@ instance TextEncoding CommandFunction where
|
||||
CFSetShortLink -> "set_short_link"
|
||||
CFGetRelayDataJoin -> "get_relay_data_join"
|
||||
CFGetRelayDataAccept -> "get_relay_data_accept"
|
||||
CFGetGroupDataInv -> "get_group_data_inv"
|
||||
|
||||
commandExpectedResponse :: CommandFunction -> AEvtTag
|
||||
commandExpectedResponse = \case
|
||||
@@ -1949,6 +1952,7 @@ commandExpectedResponse = \case
|
||||
CFSetShortLink -> t LINK_
|
||||
CFGetRelayDataJoin -> t LDATA_
|
||||
CFGetRelayDataAccept -> t LDATA_
|
||||
CFGetGroupDataInv -> t LDATA_
|
||||
where
|
||||
t = AEvtTag SAEConn
|
||||
|
||||
|
||||
Reference in New Issue
Block a user