mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-03-30 20:45:49 +00:00
core: create certain informational chat items as read (#1452)
This commit is contained in:
@@ -3058,11 +3058,12 @@ saveRcvChatItem' user cd msg sharedMsgId_ MsgMeta {broker = (_, brokerTs)} conte
|
||||
forM_ ciFile $ \CIFile {fileId} -> withStore' $ \db -> updateFileTransferChatItemId db fileId ciId
|
||||
liftIO $ mkChatItem cd ciId content ciFile quotedItem sharedMsgId_ brokerTs createdAt
|
||||
|
||||
mkChatItem :: MsgDirectionI d => ChatDirection c d -> ChatItemId -> CIContent d -> Maybe (CIFile d) -> Maybe (CIQuote c) -> Maybe SharedMsgId -> ChatItemTs -> UTCTime -> IO (ChatItem c d)
|
||||
mkChatItem :: ChatDirection c d -> ChatItemId -> CIContent d -> Maybe (CIFile d) -> Maybe (CIQuote c) -> Maybe SharedMsgId -> ChatItemTs -> UTCTime -> IO (ChatItem c d)
|
||||
mkChatItem cd ciId content file quotedItem sharedMsgId itemTs currentTs = do
|
||||
tz <- getCurrentTimeZone
|
||||
let itemText = ciContentToText content
|
||||
meta = mkCIMeta ciId content itemText ciStatusNew sharedMsgId False False tz currentTs itemTs currentTs currentTs
|
||||
itemStatus = ciCreateStatus content
|
||||
meta = mkCIMeta ciId content itemText itemStatus sharedMsgId False False tz currentTs itemTs currentTs currentTs
|
||||
pure ChatItem {chatDir = toCIDirection cd, meta, content, formattedText = parseMaybeMarkdownList itemText, quotedItem, file}
|
||||
|
||||
createAgentConnectionAsync :: forall m c. (ChatMonad m, ConnectionModeI c) => User -> CommandFunction -> Bool -> SConnectionMode c -> m (CommandId, ConnId)
|
||||
|
||||
@@ -569,6 +569,27 @@ data CIContent (d :: MsgDirection) where
|
||||
|
||||
deriving instance Show (CIContent d)
|
||||
|
||||
ciCreateStatus :: CIContent d -> CIStatus d
|
||||
ciCreateStatus = \case
|
||||
CISndMsgContent _ -> ciStatusNew
|
||||
CIRcvMsgContent _ -> ciStatusNew
|
||||
CISndDeleted _ -> ciStatusNew
|
||||
CIRcvDeleted _ -> ciStatusNew
|
||||
CISndCall {} -> ciStatusNew
|
||||
CIRcvCall {} -> ciStatusNew
|
||||
CIRcvIntegrityError _ -> ciStatusNew
|
||||
CIRcvGroupInvitation {} -> ciStatusNew
|
||||
CISndGroupInvitation {} -> ciStatusNew
|
||||
CIRcvGroupEvent rge -> rgeCreateStatus rge
|
||||
CISndGroupEvent _ -> ciStatusNew
|
||||
CIRcvConnEvent _ -> ciStatusNew
|
||||
CISndConnEvent _ -> ciStatusNew
|
||||
CIRcvChatFeature {} -> CISRcvRead
|
||||
CISndChatFeature {} -> ciStatusNew
|
||||
CIRcvGroupFeature {} -> CISRcvRead
|
||||
CISndGroupFeature {} -> ciStatusNew
|
||||
CIRcvChatFeatureRejected _ -> ciStatusNew
|
||||
|
||||
data RcvGroupEvent
|
||||
= RGEMemberAdded {groupMemberId :: GroupMemberId, profile :: Profile} -- CRJoinedGroupMemberConnecting
|
||||
| RGEMemberConnected -- CRUserJoinedGroup, CRJoinedGroupMember, CRConnectedToGroupMember
|
||||
@@ -601,6 +622,19 @@ instance ToJSON DBRcvGroupEvent where
|
||||
toJSON (RGE v) = J.genericToJSON (singleFieldJSON $ dropPrefix "RGE") v
|
||||
toEncoding (RGE v) = J.genericToEncoding (singleFieldJSON $ dropPrefix "RGE") v
|
||||
|
||||
rgeCreateStatus :: RcvGroupEvent -> CIStatus 'MDRcv
|
||||
rgeCreateStatus = \case
|
||||
RGEMemberAdded {} -> CISRcvRead
|
||||
RGEMemberConnected -> CISRcvRead
|
||||
RGEMemberLeft -> CISRcvRead
|
||||
RGEMemberRole {} -> CISRcvRead
|
||||
RGEUserRole _ -> ciStatusNew
|
||||
RGEMemberDeleted {} -> CISRcvRead
|
||||
RGEUserDeleted -> ciStatusNew
|
||||
RGEGroupDeleted -> ciStatusNew
|
||||
RGEGroupUpdated _ -> CISRcvRead
|
||||
RGEInvitedViaGroupLink -> CISRcvRead
|
||||
|
||||
data SndGroupEvent
|
||||
= SGEMemberRole {groupMemberId :: GroupMemberId, profile :: Profile, role :: GroupMemberRole}
|
||||
| SGEUserRole {role :: GroupMemberRole}
|
||||
|
||||
@@ -3128,7 +3128,7 @@ createNewChatItem_ db User {userId} chatDirection msgId_ sharedMsgId ciContent q
|
||||
pure ciId
|
||||
where
|
||||
itemRow :: (SMsgDirection d, UTCTime, CIContent d, Text, CIStatus d, Maybe SharedMsgId, UTCTime, UTCTime)
|
||||
itemRow = (msgDirection @d, itemTs, ciContent, ciContentToText ciContent, ciStatusNew @d, sharedMsgId, createdAt, createdAt)
|
||||
itemRow = (msgDirection @d, itemTs, ciContent, ciContentToText ciContent, ciCreateStatus ciContent, sharedMsgId, createdAt, createdAt)
|
||||
idsRow :: (Maybe Int64, Maybe Int64, Maybe Int64)
|
||||
idsRow = case chatDirection of
|
||||
CDDirectRcv Contact {contactId} -> (Just contactId, Nothing, Nothing)
|
||||
|
||||
Reference in New Issue
Block a user