mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
core: add multiple users tests for subscription, chat item expiration, timed messages (#1840)
This commit is contained in:
+11
-8
@@ -108,7 +108,8 @@ defaultChatConfig =
|
||||
subscriptionConcurrency = 16,
|
||||
subscriptionEvents = False,
|
||||
hostEvents = False,
|
||||
testView = False
|
||||
testView = False,
|
||||
ciExpirationInterval = 1800 * 1000000 -- 30 minutes
|
||||
}
|
||||
|
||||
_defaultSMPServers :: NonEmpty SMPServerWithAuth
|
||||
@@ -1565,13 +1566,15 @@ startExpireCIThread user@User {userId} = do
|
||||
atomically $ TM.insert userId a expireThreads
|
||||
_ -> pure ()
|
||||
where
|
||||
runExpireCIs = forever $ do
|
||||
flip catchError (toView . CRChatError (Just user)) $ do
|
||||
expireFlags <- asks expireCIFlags
|
||||
atomically $ TM.lookup userId expireFlags >>= \b -> unless (b == Just True) retry
|
||||
ttl <- withStore' (`getChatItemTTL` user)
|
||||
forM_ ttl $ \t -> expireChatItems user t False
|
||||
threadDelay $ 1800 * 1000000 -- 30 minutes
|
||||
runExpireCIs = do
|
||||
interval <- asks $ ciExpirationInterval . config
|
||||
forever $ do
|
||||
flip catchError (toView . CRChatError (Just user)) $ do
|
||||
expireFlags <- asks expireCIFlags
|
||||
atomically $ TM.lookup userId expireFlags >>= \b -> unless (b == Just True) retry
|
||||
ttl <- withStore' (`getChatItemTTL` user)
|
||||
forM_ ttl $ \t -> expireChatItems user t False
|
||||
threadDelay interval
|
||||
|
||||
setExpireCIFlag :: (MonadUnliftIO m, MonadReader ChatController m) => User -> Bool -> m ()
|
||||
setExpireCIFlag User {userId} b = do
|
||||
|
||||
@@ -109,7 +109,8 @@ data ChatConfig = ChatConfig
|
||||
subscriptionEvents :: Bool,
|
||||
hostEvents :: Bool,
|
||||
logLevel :: ChatLogLevel,
|
||||
testView :: Bool
|
||||
testView :: Bool,
|
||||
ciExpirationInterval :: Int -- microseconds
|
||||
}
|
||||
|
||||
data DefaultAgentServers = DefaultAgentServers
|
||||
|
||||
Reference in New Issue
Block a user