mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-18 11:56:40 +00:00
add to info
This commit is contained in:
+10
-1
@@ -705,7 +705,16 @@ processChatCommand' vr = \case
|
||||
[] -> pure Nothing
|
||||
memStatuses -> pure $ Just $ map (uncurry MemberDeliveryStatus) memStatuses
|
||||
_ -> pure Nothing
|
||||
pure $ CRChatItemInfo user aci ChatItemInfo {itemVersions, memberDeliveryStatuses}
|
||||
forwardedFromChatItem <- getForwardedFromItem user ci
|
||||
pure $ CRChatItemInfo user aci ChatItemInfo {itemVersions, memberDeliveryStatuses, forwardedFromChatItem}
|
||||
where
|
||||
getForwardedFromItem :: User -> ChatItem c d -> CM (Maybe AChatItem)
|
||||
getForwardedFromItem user ChatItem {meta = CIMeta {itemForwarded}} = case itemForwarded of
|
||||
Just (CIFFContact _ _ (Just ctId) (Just fwdItemId)) ->
|
||||
Just <$> withStore (\db -> getAChatItem db vr user (ChatRef CTDirect ctId) fwdItemId)
|
||||
Just (CIFFGroup _ _ (Just gId) (Just fwdItemId)) ->
|
||||
Just <$> withStore (\db -> getAChatItem db vr user (ChatRef CTGroup gId) fwdItemId)
|
||||
_ -> pure Nothing
|
||||
APISendMessage (ChatRef cType chatId) live itemTTL cm -> withUser $ \user -> case cType of
|
||||
CTDirect -> withContactLock "sendMessage" chatId $
|
||||
sendContactContentMessage user chatId live itemTTL cm Nothing
|
||||
|
||||
@@ -1031,9 +1031,10 @@ instance TextEncoding CIForwardedFromTag where
|
||||
|
||||
data ChatItemInfo = ChatItemInfo
|
||||
{ itemVersions :: [ChatItemVersion],
|
||||
memberDeliveryStatuses :: Maybe [MemberDeliveryStatus]
|
||||
memberDeliveryStatuses :: Maybe [MemberDeliveryStatus],
|
||||
forwardedFromChatItem :: Maybe AChatItem
|
||||
}
|
||||
deriving (Eq, Show)
|
||||
deriving (Show)
|
||||
|
||||
data ChatItemVersion = ChatItemVersion
|
||||
{ chatItemVersionId :: Int64,
|
||||
@@ -1116,8 +1117,6 @@ $(JQ.deriveJSON defaultJSON ''MemberDeliveryStatus)
|
||||
|
||||
$(JQ.deriveJSON defaultJSON ''ChatItemVersion)
|
||||
|
||||
$(JQ.deriveJSON defaultJSON ''ChatItemInfo)
|
||||
|
||||
instance (ChatTypeI c, MsgDirectionI d) => FromJSON (CIMeta c d) where
|
||||
parseJSON = $(JQ.mkParseJSON defaultJSON ''CIMeta)
|
||||
|
||||
@@ -1207,6 +1206,8 @@ instance ChatTypeI c => ToJSON (CChatItem c) where
|
||||
toJSON (CChatItem _ ci) = J.toJSON ci
|
||||
toEncoding (CChatItem _ ci) = J.toEncoding ci
|
||||
|
||||
$(JQ.deriveJSON defaultJSON ''ChatItemInfo)
|
||||
|
||||
$(JQ.deriveJSON defaultJSON ''ChatStats)
|
||||
|
||||
instance ChatTypeI c => ToJSON (Chat c) where
|
||||
|
||||
@@ -625,11 +625,12 @@ viewChatItem chat ci@ChatItem {chatDir, meta = meta@CIMeta {itemForwarded, forwa
|
||||
prohibited = styled (colored Red) ("[unexpected chat item created, please report to developers]" :: String)
|
||||
|
||||
viewChatItemInfo :: AChatItem -> ChatItemInfo -> TimeZone -> [StyledString]
|
||||
viewChatItemInfo (AChatItem _ msgDir _ ChatItem {meta = CIMeta {itemTs, itemTimed, createdAt}}) ChatItemInfo {itemVersions} tz =
|
||||
viewChatItemInfo (AChatItem _ msgDir _ ChatItem {meta = CIMeta {itemTs, itemTimed, createdAt}}) ChatItemInfo {itemVersions, forwardedFromChatItem} tz =
|
||||
["sent at: " <> ts itemTs]
|
||||
<> receivedAt
|
||||
<> toBeDeletedAt
|
||||
<> versions
|
||||
<> forwardedFromItemId
|
||||
where
|
||||
ts = styleTime . localTs tz
|
||||
receivedAt = case msgDir of
|
||||
@@ -642,7 +643,12 @@ viewChatItemInfo (AChatItem _ msgDir _ ChatItem {meta = CIMeta {itemTs, itemTime
|
||||
if null itemVersions
|
||||
then []
|
||||
else ["message history:"] <> concatMap version itemVersions
|
||||
version ChatItemVersion {msgContent, itemVersionTs} = prependFirst (ts itemVersionTs <> styleTime ": ") $ ttyMsgContent msgContent
|
||||
where
|
||||
version ChatItemVersion {msgContent, itemVersionTs} = prependFirst (ts itemVersionTs <> styleTime ": ") $ ttyMsgContent msgContent
|
||||
forwardedFromItemId =
|
||||
case forwardedFromChatItem of
|
||||
Just aci -> ["forwarded from chat item id: " <> (plain . show) (aChatItemId aci)]
|
||||
_ -> []
|
||||
|
||||
localTs :: TimeZone -> UTCTime -> String
|
||||
localTs tz ts = do
|
||||
|
||||
@@ -54,6 +54,7 @@ testForwardContactToContact =
|
||||
cath <# "alice> -> forwarded"
|
||||
cath <## " hey"
|
||||
|
||||
-- read chat
|
||||
alice ##> "/tail @cath 2"
|
||||
alice <# "@cath -> from you"
|
||||
alice <## " hi"
|
||||
@@ -66,6 +67,13 @@ testForwardContactToContact =
|
||||
cath <# "alice> -> forwarded"
|
||||
cath <## " hey"
|
||||
|
||||
-- item info
|
||||
alice ##> "/item info @cath hey"
|
||||
alice <##. "sent at: "
|
||||
alice <## "message history:"
|
||||
alice .<## ": hey"
|
||||
alice <##. "forwarded from chat item id:"
|
||||
|
||||
testForwardContactToGroup :: HasCallStack => FilePath -> IO ()
|
||||
testForwardContactToGroup =
|
||||
testChat3 aliceProfile bobProfile cathProfile $
|
||||
|
||||
Reference in New Issue
Block a user