mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-06-28 20:29:53 +00:00
rename, fix tests
This commit is contained in:
parent
dcae8a304a
commit
16e424bade
3 changed files with 16 additions and 15 deletions
|
@ -1746,7 +1746,7 @@ processChatCommand' vr = \case
|
||||||
groupProfile = businessGroupProfile profile groupPreferences
|
groupProfile = businessGroupProfile profile groupPreferences
|
||||||
(gInfo, hostMember) <- withStore $ \db -> createPreparedGroup db vr user groupProfile True ccLink welcomeSharedMsgId
|
(gInfo, hostMember) <- withStore $ \db -> createPreparedGroup db vr user groupProfile True ccLink welcomeSharedMsgId
|
||||||
let cd = CDGroupRcv gInfo Nothing hostMember
|
let cd = CDGroupRcv gInfo Nothing hostMember
|
||||||
createItem sharedMsgId content = createInternalItemForChat user cd True content sharedMsgId Nothing
|
createItem sharedMsgId content = createChatItem user cd True content sharedMsgId Nothing
|
||||||
cInfo = GroupChat gInfo Nothing
|
cInfo = GroupChat gInfo Nothing
|
||||||
void $ createGroupFeatureItems_ user cd True CIRcvGroupFeature gInfo
|
void $ createGroupFeatureItems_ user cd True CIRcvGroupFeature gInfo
|
||||||
aci <- mapM (createItem welcomeSharedMsgId . CIRcvMsgContent . MCText) message
|
aci <- mapM (createItem welcomeSharedMsgId . CIRcvMsgContent . MCText) message
|
||||||
|
@ -1756,7 +1756,7 @@ processChatCommand' vr = \case
|
||||||
pure $ CRNewPreparedChat user $ AChat SCTGroup chat
|
pure $ CRNewPreparedChat user $ AChat SCTGroup chat
|
||||||
ACCL _ (CCLink cReq _) -> do
|
ACCL _ (CCLink cReq _) -> do
|
||||||
ct <- withStore $ \db -> createPreparedContact db user profile accLink welcomeSharedMsgId
|
ct <- withStore $ \db -> createPreparedContact db user profile accLink welcomeSharedMsgId
|
||||||
let createItem sharedMsgId content = createInternalItemForChat user (CDDirectRcv ct) False content sharedMsgId Nothing
|
let createItem sharedMsgId content = createChatItem user (CDDirectRcv ct) False content sharedMsgId Nothing
|
||||||
cInfo = DirectChat ct
|
cInfo = DirectChat ct
|
||||||
void $ createItem Nothing $ CIRcvDirectE2EEInfo $ E2EInfo $ connRequestPQEncryption cReq
|
void $ createItem Nothing $ CIRcvDirectE2EEInfo $ E2EInfo $ connRequestPQEncryption cReq
|
||||||
void $ createFeatureEnabledItems_ user ct
|
void $ createFeatureEnabledItems_ user ct
|
||||||
|
@ -1769,7 +1769,7 @@ processChatCommand' vr = \case
|
||||||
let GroupShortLinkData {groupProfile = gp@GroupProfile {description}} = groupSLinkData
|
let GroupShortLinkData {groupProfile = gp@GroupProfile {description}} = groupSLinkData
|
||||||
(gInfo, hostMember) <- withStore $ \db -> createPreparedGroup db vr user gp False ccLink Nothing
|
(gInfo, hostMember) <- withStore $ \db -> createPreparedGroup db vr user gp False ccLink Nothing
|
||||||
let cd = CDGroupRcv gInfo Nothing hostMember
|
let cd = CDGroupRcv gInfo Nothing hostMember
|
||||||
createItem content = createInternalItemForChat user cd True content Nothing Nothing
|
createItem content = createChatItem user cd True content Nothing Nothing
|
||||||
cInfo = GroupChat gInfo Nothing
|
cInfo = GroupChat gInfo Nothing
|
||||||
void $ createGroupFeatureItems_ user cd True CIRcvGroupFeature gInfo
|
void $ createGroupFeatureItems_ user cd True CIRcvGroupFeature gInfo
|
||||||
aci <- mapM (createItem . CIRcvMsgContent . MCText) description
|
aci <- mapM (createItem . CIRcvMsgContent . MCText) description
|
||||||
|
@ -1813,8 +1813,9 @@ processChatCommand' vr = \case
|
||||||
CRSentInvitation {customUserProfile} -> do
|
CRSentInvitation {customUserProfile} -> do
|
||||||
-- get updated contact with connection
|
-- get updated contact with connection
|
||||||
ct' <- withFastStore $ \db -> getContact db vr user contactId
|
ct' <- withFastStore $ \db -> getContact db vr user contactId
|
||||||
forM_ msg_ $ \(sharedMsgId, mc) ->
|
forM_ msg_ $ \(sharedMsgId, mc) -> do
|
||||||
createInternalItemForChat user (CDDirectSnd ct') False (CISndMsgContent mc) (Just sharedMsgId) Nothing
|
ci <- createChatItem user (CDDirectSnd ct') False (CISndMsgContent mc) (Just sharedMsgId) Nothing
|
||||||
|
toView $ CEvtNewChatItems user [ci]
|
||||||
pure $ CRStartedConnectionToContact user ct' customUserProfile
|
pure $ CRStartedConnectionToContact user ct' customUserProfile
|
||||||
cr -> pure cr
|
cr -> pure cr
|
||||||
APIConnectPreparedGroup groupId incognito msgContent_ -> withUser $ \user -> do
|
APIConnectPreparedGroup groupId incognito msgContent_ -> withUser $ \user -> do
|
||||||
|
|
|
@ -2289,7 +2289,7 @@ createFeatureEnabledItems_ :: User -> Contact -> CM [AChatItem]
|
||||||
createFeatureEnabledItems_ user ct@Contact {mergedPreferences} =
|
createFeatureEnabledItems_ user ct@Contact {mergedPreferences} =
|
||||||
forM allChatFeatures $ \(ACF f) -> do
|
forM allChatFeatures $ \(ACF f) -> do
|
||||||
let state = featureState $ getContactUserPreference f mergedPreferences
|
let state = featureState $ getContactUserPreference f mergedPreferences
|
||||||
createInternalItemForChat user (CDDirectRcv ct) False (uncurry (CIRcvChatFeature $ chatFeature f) state) Nothing Nothing
|
createChatItem user (CDDirectRcv ct) False (uncurry (CIRcvChatFeature $ chatFeature f) state) Nothing Nothing
|
||||||
|
|
||||||
createFeatureItems ::
|
createFeatureItems ::
|
||||||
MsgDirectionI d =>
|
MsgDirectionI d =>
|
||||||
|
@ -2315,7 +2315,7 @@ createContactsFeatureItems ::
|
||||||
CM' ()
|
CM' ()
|
||||||
createContactsFeatureItems user cts chatDir ciFeature ciOffer getPref = do
|
createContactsFeatureItems user cts chatDir ciFeature ciOffer getPref = do
|
||||||
let dirsCIContents = map contactChangedFeatures cts
|
let dirsCIContents = map contactChangedFeatures cts
|
||||||
(errs, acis) <- partitionEithers <$> createInternalItemsForChats user Nothing dirsCIContents
|
(errs, acis) <- partitionEithers <$> createChatItems user Nothing dirsCIContents
|
||||||
unless (null errs) $ toView' $ CEvtChatErrors errs
|
unless (null errs) $ toView' $ CEvtChatErrors errs
|
||||||
toView' $ CEvtNewChatItems user acis
|
toView' $ CEvtNewChatItems user acis
|
||||||
where
|
where
|
||||||
|
@ -2360,30 +2360,30 @@ createGroupFeatureItems_ user cd showGroupAsSender ciContent GroupInfo {fullGrou
|
||||||
forM allGroupFeatures $ \(AGF f) -> do
|
forM allGroupFeatures $ \(AGF f) -> do
|
||||||
let p = getGroupPreference f fullGroupPreferences
|
let p = getGroupPreference f fullGroupPreferences
|
||||||
(_, param, role) = groupFeatureState p
|
(_, param, role) = groupFeatureState p
|
||||||
createInternalItemForChat user cd showGroupAsSender (ciContent (toGroupFeature f) (toGroupPreference p) param role) Nothing Nothing
|
createChatItem user cd showGroupAsSender (ciContent (toGroupFeature f) (toGroupPreference p) param role) Nothing Nothing
|
||||||
|
|
||||||
createInternalChatItem :: (ChatTypeI c, MsgDirectionI d) => User -> ChatDirection c d -> CIContent d -> Maybe UTCTime -> CM ()
|
createInternalChatItem :: (ChatTypeI c, MsgDirectionI d) => User -> ChatDirection c d -> CIContent d -> Maybe UTCTime -> CM ()
|
||||||
createInternalChatItem user cd content itemTs_ = do
|
createInternalChatItem user cd content itemTs_ = do
|
||||||
ci <- createInternalItemForChat user cd False content Nothing itemTs_
|
ci <- createChatItem user cd False content Nothing itemTs_
|
||||||
toView $ CEvtNewChatItems user [ci]
|
toView $ CEvtNewChatItems user [ci]
|
||||||
|
|
||||||
createInternalItemForChat :: (ChatTypeI c, MsgDirectionI d) => User -> ChatDirection c d -> ShowGroupAsSender -> CIContent d -> Maybe SharedMsgId -> Maybe UTCTime -> CM AChatItem
|
createChatItem :: (ChatTypeI c, MsgDirectionI d) => User -> ChatDirection c d -> ShowGroupAsSender -> CIContent d -> Maybe SharedMsgId -> Maybe UTCTime -> CM AChatItem
|
||||||
createInternalItemForChat user cd showGroupAsSender content sharedMsgId itemTs_ =
|
createChatItem user cd showGroupAsSender content sharedMsgId itemTs_ =
|
||||||
lift (createInternalItemsForChats user itemTs_ [(cd, showGroupAsSender, [(content, sharedMsgId)])]) >>= \case
|
lift (createChatItems user itemTs_ [(cd, showGroupAsSender, [(content, sharedMsgId)])]) >>= \case
|
||||||
[Right ci] -> pure ci
|
[Right ci] -> pure ci
|
||||||
[Left e] -> throwError e
|
[Left e] -> throwError e
|
||||||
rs -> throwChatError $ CEInternalError $ "createInternalChatItem: expected 1 result, got " <> show (length rs)
|
rs -> throwChatError $ CEInternalError $ "createInternalChatItem: expected 1 result, got " <> show (length rs)
|
||||||
|
|
||||||
-- Supports items with shared msg ID that are created for all conversation parties, but were not communicated via the usual messages.
|
-- Supports items with shared msg ID that are created for all conversation parties, but were not communicated via the usual messages.
|
||||||
-- This includes address welcome message and contact request message.
|
-- This includes address welcome message and contact request message.
|
||||||
createInternalItemsForChats ::
|
createChatItems ::
|
||||||
forall c d.
|
forall c d.
|
||||||
(ChatTypeI c, MsgDirectionI d) =>
|
(ChatTypeI c, MsgDirectionI d) =>
|
||||||
User ->
|
User ->
|
||||||
Maybe UTCTime ->
|
Maybe UTCTime ->
|
||||||
[(ChatDirection c d, ShowGroupAsSender, [(CIContent d, Maybe SharedMsgId)])] ->
|
[(ChatDirection c d, ShowGroupAsSender, [(CIContent d, Maybe SharedMsgId)])] ->
|
||||||
CM' [Either ChatError AChatItem]
|
CM' [Either ChatError AChatItem]
|
||||||
createInternalItemsForChats user itemTs_ dirsCIContents = do
|
createChatItems user itemTs_ dirsCIContents = do
|
||||||
createdAt <- liftIO getCurrentTime
|
createdAt <- liftIO getCurrentTime
|
||||||
let itemTs = fromMaybe createdAt itemTs_
|
let itemTs = fromMaybe createdAt itemTs_
|
||||||
vr <- chatVersionRange'
|
vr <- chatVersionRange'
|
||||||
|
|
|
@ -1253,7 +1253,7 @@ processAgentMessageConn vr user@User {userId} corrId agentConnId agentMessage =
|
||||||
if newRequest
|
if newRequest
|
||||||
then do
|
then do
|
||||||
-- TODO [short links] save sharedMsgId instead of the last Nothing
|
-- TODO [short links] save sharedMsgId instead of the last Nothing
|
||||||
let createItem content = createInternalItemForChat user (CDDirectRcv ct) False content Nothing Nothing
|
let createItem content = createChatItem user (CDDirectRcv ct) False content Nothing Nothing
|
||||||
void $ createItem $ CIRcvDirectE2EEInfo $ E2EInfo $ Just $ CR.pqSupportToEnc $ reqPQSup
|
void $ createItem $ CIRcvDirectE2EEInfo $ E2EInfo $ Just $ CR.pqSupportToEnc $ reqPQSup
|
||||||
void $ createFeatureEnabledItems_ user ct
|
void $ createFeatureEnabledItems_ user ct
|
||||||
-- TODO [short links] save sharedMsgId
|
-- TODO [short links] save sharedMsgId
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue