core: add timestamp to call invitation (#700)

This commit is contained in:
Evgeny Poberezkin
2022-05-27 06:30:01 +01:00
committed by GitHub
parent 9e83b54b85
commit a403f2051a
4 changed files with 9 additions and 5 deletions

View File

@@ -1678,7 +1678,7 @@ processAgentMessage (Just user@User {userId, profile}) agentConnId agentMessage
-- practically, this should not happen -- practically, this should not happen
call_ <- atomically (TM.lookupInsert contactId call' calls) call_ <- atomically (TM.lookupInsert contactId call' calls)
forM_ call_ $ \call -> updateCallItemStatus userId ct call WCSDisconnected Nothing forM_ call_ $ \call -> updateCallItemStatus userId ct call WCSDisconnected Nothing
toView $ CRCallInvitation ct callType sharedKey toView . CRCallInvitation ct callType sharedKey $ chatItemTs' ci
toView . CRNewChatItem $ AChatItem SCTDirect SMDRcv (DirectChat ct) ci toView . CRNewChatItem $ AChatItem SCTDirect SMDRcv (DirectChat ct) ci
where where
saveCallItem status = saveRcvChatItem user (CDDirectRcv ct) msg msgMeta (CIRcvCall status 0) Nothing saveCallItem status = saveRcvChatItem user (CDDirectRcv ct) msg msgMeta (CIRcvCall status 0) Nothing

View File

@@ -21,6 +21,7 @@ import Data.Int (Int64)
import Data.Map.Strict (Map) import Data.Map.Strict (Map)
import Data.Text (Text) import Data.Text (Text)
import Data.Time (ZonedTime) import Data.Time (ZonedTime)
import Data.Time.Clock (UTCTime)
import Data.Version (showVersion) import Data.Version (showVersion)
import Data.Word (Word16) import Data.Word (Word16)
import GHC.Generics (Generic) import GHC.Generics (Generic)
@@ -259,7 +260,7 @@ data ChatResponse
| CRPendingSubSummary {pendingSubStatus :: [PendingSubStatus]} | CRPendingSubSummary {pendingSubStatus :: [PendingSubStatus]}
| CRSndFileSubError {sndFileTransfer :: SndFileTransfer, chatError :: ChatError} | CRSndFileSubError {sndFileTransfer :: SndFileTransfer, chatError :: ChatError}
| CRRcvFileSubError {rcvFileTransfer :: RcvFileTransfer, chatError :: ChatError} | CRRcvFileSubError {rcvFileTransfer :: RcvFileTransfer, chatError :: ChatError}
| CRCallInvitation {contact :: Contact, callType :: CallType, sharedKey :: Maybe C.Key} | CRCallInvitation {contact :: Contact, callType :: CallType, sharedKey :: Maybe C.Key, callTs :: UTCTime}
| CRCallOffer {contact :: Contact, callType :: CallType, offer :: WebRTCSession, sharedKey :: Maybe C.Key, askConfirmation :: Bool} | CRCallOffer {contact :: Contact, callType :: CallType, offer :: WebRTCSession, sharedKey :: Maybe C.Key, askConfirmation :: Bool}
| CRCallAnswer {contact :: Contact, answer :: WebRTCSession} | CRCallAnswer {contact :: Contact, answer :: WebRTCSession}
| CRCallExtraInfo {contact :: Contact, extraInfo :: WebRTCExtraInfo} | CRCallExtraInfo {contact :: Contact, extraInfo :: WebRTCExtraInfo}

View File

@@ -152,6 +152,12 @@ instance ToJSON (CChatItem c) where
chatItemId' :: ChatItem c d -> ChatItemId chatItemId' :: ChatItem c d -> ChatItemId
chatItemId' ChatItem {meta = CIMeta {itemId}} = itemId chatItemId' ChatItem {meta = CIMeta {itemId}} = itemId
chatItemTs :: CChatItem c -> UTCTime
chatItemTs (CChatItem _ ci) = chatItemTs' ci
chatItemTs' :: ChatItem c d -> UTCTime
chatItemTs' ChatItem {meta = CIMeta {itemTs}} = itemTs
data ChatDirection (c :: ChatType) (d :: MsgDirection) where data ChatDirection (c :: ChatType) (d :: MsgDirection) where
CDDirectSnd :: Contact -> ChatDirection 'CTDirect 'MDSnd CDDirectSnd :: Contact -> ChatDirection 'CTDirect 'MDSnd
CDDirectRcv :: Contact -> ChatDirection 'CTDirect 'MDRcv CDDirectRcv :: Contact -> ChatDirection 'CTDirect 'MDRcv

View File

@@ -2640,9 +2640,6 @@ getChatPreviews st user withPCC =
ts (AChat _ Chat {chatInfo, chatItems = ci : _}) = max (chatItemTs ci) (chatInfoUpdatedAt chatInfo) ts (AChat _ Chat {chatInfo, chatItems = ci : _}) = max (chatItemTs ci) (chatInfoUpdatedAt chatInfo)
ts (AChat _ Chat {chatInfo}) = chatInfoUpdatedAt chatInfo ts (AChat _ Chat {chatInfo}) = chatInfoUpdatedAt chatInfo
chatItemTs :: CChatItem d -> UTCTime
chatItemTs (CChatItem _ ChatItem {meta = CIMeta {itemTs}}) = itemTs
getDirectChatPreviews_ :: DB.Connection -> User -> IO [AChat] getDirectChatPreviews_ :: DB.Connection -> User -> IO [AChat]
getDirectChatPreviews_ db User {userId} = do getDirectChatPreviews_ db User {userId} = do
tz <- getCurrentTimeZone tz <- getCurrentTimeZone