mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-26 18:10:04 +00:00
core: use Int64 in time calculations (#2143)
* core: use Int64 in time calculations * remove import * make interval Int64
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ constraints: zip +disable-bzip2 +disable-zstd
|
||||
source-repository-package
|
||||
type: git
|
||||
location: https://github.com/simplex-chat/simplexmq.git
|
||||
tag: c6033e51a04b66523ab4580c067b8cb0b87fd452
|
||||
tag: 44f0dd39f3d1536c979b09e268dbdf681f9b0bb8
|
||||
|
||||
source-repository-package
|
||||
type: git
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"https://github.com/simplex-chat/simplexmq.git"."c6033e51a04b66523ab4580c067b8cb0b87fd452" = "119fyks79dn1z73r1y259aagcw31hrpdlmx1wqip6i0p5bgbs6vj";
|
||||
"https://github.com/simplex-chat/simplexmq.git"."44f0dd39f3d1536c979b09e268dbdf681f9b0bb8" = "0dh0q2vng374kkq8s1lnnv658xfv6q7b9cgshiqxs9hxij64kxav";
|
||||
"https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38";
|
||||
"https://github.com/kazu-yamamoto/http2.git"."159417b413a684a9b754e10e4a5db4376aa8c6b9" = "17jjw582f4ls1m14abym1p0xlpjx1viqsfcpl4fkykv0sksbxdg7";
|
||||
"https://github.com/simplex-chat/direct-sqlcipher.git"."34309410eb2069b029b8fc1872deb1e0db123294" = "0kwkmhyfsn2lixdlgl15smgr1h5gjk7fky6abzh8rng2h5ymnffd";
|
||||
|
||||
+4
-5
@@ -57,7 +57,6 @@ import Simplex.Chat.ProfileGenerator (generateRandomProfile)
|
||||
import Simplex.Chat.Protocol
|
||||
import Simplex.Chat.Store
|
||||
import Simplex.Chat.Types
|
||||
import Simplex.Chat.Util (diffInMicros, diffInSeconds)
|
||||
import Simplex.FileTransfer.Client.Presets (defaultXFTPServers)
|
||||
import Simplex.FileTransfer.Description (ValidFileDescription, gb, kb, mb)
|
||||
import Simplex.FileTransfer.Protocol (FileParty (..))
|
||||
@@ -1778,7 +1777,7 @@ startExpireCIThread user@User {userId} = do
|
||||
atomically $ TM.lookup userId expireFlags >>= \b -> unless (b == Just True) retry
|
||||
ttl <- withStore' (`getChatItemTTL` user)
|
||||
forM_ ttl $ \t -> expireChatItems user t False
|
||||
threadDelay interval
|
||||
liftIO $ threadDelay' interval
|
||||
|
||||
setExpireCIFlag :: ChatMonad' m => User -> Bool -> m ()
|
||||
setExpireCIFlag User {userId} b = do
|
||||
@@ -2174,7 +2173,7 @@ subscribeUserConnections agentBatchSubscribe user = do
|
||||
Just _ -> Nothing
|
||||
_ -> Just . ChatError . CEAgentNoSubResult $ AgentConnId connId
|
||||
|
||||
cleanupManagerInterval :: Int
|
||||
cleanupManagerInterval :: Int64
|
||||
cleanupManagerInterval = 1800 -- 30 minutes
|
||||
|
||||
cleanupManager :: forall m. ChatMonad m => m ()
|
||||
@@ -2186,7 +2185,7 @@ cleanupManager = do
|
||||
let (us, us') = partition activeUser users
|
||||
forM_ us cleanupUser
|
||||
forM_ us' cleanupUser
|
||||
threadDelay $ cleanupManagerInterval * 1000000
|
||||
liftIO $ threadDelay' $ cleanupManagerInterval * 1000000
|
||||
where
|
||||
cleanupUser user =
|
||||
cleanupTimedItems user `catchError` (toView . CRChatError (Just user))
|
||||
@@ -2220,7 +2219,7 @@ startTimedItemThread user itemRef deleteAt = do
|
||||
deleteTimedItem :: ChatMonad m => User -> (ChatRef, ChatItemId) -> UTCTime -> m ()
|
||||
deleteTimedItem user (ChatRef cType chatId, itemId) deleteAt = do
|
||||
ts <- liftIO getCurrentTime
|
||||
threadDelay $ diffInMicros deleteAt ts
|
||||
liftIO $ threadDelay' $ diffInMicros deleteAt ts
|
||||
waitChatStarted
|
||||
case cType of
|
||||
CTDirect -> do
|
||||
|
||||
@@ -113,7 +113,7 @@ data ChatConfig = ChatConfig
|
||||
hostEvents :: Bool,
|
||||
logLevel :: ChatLogLevel,
|
||||
testView :: Bool,
|
||||
ciExpirationInterval :: Int -- microseconds
|
||||
ciExpirationInterval :: Int64 -- microseconds
|
||||
}
|
||||
|
||||
data DefaultAgentServers = DefaultAgentServers
|
||||
|
||||
@@ -1,27 +1,6 @@
|
||||
{-# LANGUAGE NumericUnderscores #-}
|
||||
module Simplex.Chat.Util (week) where
|
||||
|
||||
module Simplex.Chat.Util
|
||||
( diffInMicros,
|
||||
diffInSeconds,
|
||||
week,
|
||||
)
|
||||
where
|
||||
|
||||
import Data.Fixed (Fixed (MkFixed), Pico)
|
||||
import Data.Time (NominalDiffTime, nominalDiffTimeToSeconds)
|
||||
import Data.Time.Clock (UTCTime, diffUTCTime)
|
||||
|
||||
diffInSeconds :: UTCTime -> UTCTime -> Int
|
||||
diffInSeconds a b = (`div` 1000000_000000) $ diffInPicos a b
|
||||
|
||||
diffInMicros :: UTCTime -> UTCTime -> Int
|
||||
diffInMicros a b = (`div` 1000000) $ diffInPicos a b
|
||||
|
||||
diffInPicos :: UTCTime -> UTCTime -> Int
|
||||
diffInPicos a b = fromInteger . fromPico . nominalDiffTimeToSeconds $ diffUTCTime a b
|
||||
|
||||
fromPico :: Pico -> Integer
|
||||
fromPico (MkFixed i) = i
|
||||
import Data.Time (NominalDiffTime)
|
||||
|
||||
week :: NominalDiffTime
|
||||
week = 7 * 86400
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ extra-deps:
|
||||
# - simplexmq-1.0.0@sha256:34b2004728ae396e3ae449cd090ba7410781e2b3cefc59259915f4ca5daa9ea8,8561
|
||||
# - ../simplexmq
|
||||
- github: simplex-chat/simplexmq
|
||||
commit: c6033e51a04b66523ab4580c067b8cb0b87fd452
|
||||
commit: 44f0dd39f3d1536c979b09e268dbdf681f9b0bb8
|
||||
- github: kazu-yamamoto/http2
|
||||
commit: 159417b413a684a9b754e10e4a5db4376aa8c6b9
|
||||
# - ../direct-sqlcipher
|
||||
|
||||
Reference in New Issue
Block a user