refactor groups (#84)

* refactor groups

* disable chat test

* remove comments
This commit is contained in:
Evgeny Poberezkin
2021-07-24 18:11:04 +01:00
committed by GitHub
parent 189cd7e09d
commit 488df1aa3c
4 changed files with 195 additions and 167 deletions
+6 -2
View File
@@ -29,8 +29,7 @@ import Simplex.Messaging.Parsers (parseAll)
import Simplex.Messaging.Util (bshow)
data ChatDirection (p :: AParty) where
ReceivedDMConnection :: Connection -> ChatDirection 'Agent
ReceivedDMContact :: Contact -> ChatDirection 'Agent
ReceivedDirectMessage :: Connection -> Maybe Contact -> ChatDirection 'Agent
SentDirectMessage :: Contact -> ChatDirection 'Client
ReceivedGroupMessage :: Connection -> GroupName -> GroupMember -> ChatDirection 'Agent
SentGroupMessage :: GroupName -> ChatDirection 'Client
@@ -39,6 +38,11 @@ deriving instance Eq (ChatDirection p)
deriving instance Show (ChatDirection p)
fromConnection :: ChatDirection 'Agent -> Connection
fromConnection = \case
ReceivedDirectMessage conn _ -> conn
ReceivedGroupMessage conn _ _ -> conn
data ChatMsgEvent
= XMsgNew MsgContent
| XInfo Profile
+3 -3
View File
@@ -292,9 +292,9 @@ getConnectionChatDirection st User {userId, userContactId} agentConnId =
Nothing -> throwError $ SEInternal "group member without connection"
Just groupMemberId -> uncurry (ReceivedGroupMessage c) <$> getGroupAndMember_ db groupMemberId c
ConnContact ->
case entityId of
Nothing -> pure $ ReceivedDMConnection c
Just contactId -> ReceivedDMContact <$> getContact_ db contactId c
ReceivedDirectMessage c <$> case entityId of
Nothing -> pure Nothing
Just contactId -> Just <$> getContact_ db contactId c
where
getConnection_ :: DB.Connection -> ExceptT StoreError IO Connection
getConnection_ db = ExceptT $ do