diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2025-11-16 19:38:14 +0100 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-11-19 23:41:04 +0100 |
| commit | e1765a3e39cfb0a1c1b53e38a6b1d36592566ef1 (patch) | |
| tree | 877d7bfd991f7a21cc016dbcf48773120595f6f8 /main | |
| parent | 5be8f266e0af73917d8b73797c94333f7806b7c8 (diff) | |
Diffstat (limited to 'main')
| -rw-r--r-- | main/Test.hs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/main/Test.hs b/main/Test.hs index 17dc228..da49257 100644 --- a/main/Test.hs +++ b/main/Test.hs @@ -268,12 +268,13 @@ inviteAttributes out = (defaultServiceAttributes Proxy) dmThreadWatcher :: ComposedIdentity -> Output -> DirectMessageThread -> DirectMessageThread -> IO () dmThreadWatcher self out prev cur = do - forM_ (reverse $ dmThreadToListSince prev cur) $ \msg -> do + forM_ (reverse $ dmThreadToListSinceUnread prev cur) $ \( msg, new ) -> do outLine out $ unwords [ if sameIdentity self (msgFrom msg) then "dm-sent" else "dm-received" , "from", maybe "<unnamed>" T.unpack $ idName $ msgFrom msg + , "new", if new then "yes" else "no" , "text", T.unpack $ msgText msg ] @@ -347,6 +348,8 @@ commands = , ( "dm-send-identity", cmdDmSendIdentity ) , ( "dm-list-peer", cmdDmListPeer ) , ( "dm-list-contact", cmdDmListContact ) + , ( "dm-list-identity", cmdDmListIdentity ) + , ( "dm-mark-seen", cmdDmMarkSeen ) , ( "chatroom-create", cmdChatroomCreate ) , ( "chatroom-delete", cmdChatroomDelete ) , ( "chatroom-list-local", cmdChatroomListLocal ) @@ -934,8 +937,9 @@ dmList peer = do threads <- dmThreadList . lookupSharedValue . lsShared . headObject <$> getHead case find (sameIdentity peer . msgPeer) threads of Just thread -> do - forM_ (reverse $ dmThreadToList thread) $ \DirectMessage {..} -> cmdOut $ "dm-list-item" + forM_ (reverse $ dmThreadToListUnread thread) $ \( DirectMessage {..}, new ) -> cmdOut $ "dm-list-item" <> " from " <> (maybe "<unnamed>" T.unpack $ idName msgFrom) + <> " new " <> (if new then "yes" else "no") <> " text " <> (T.unpack msgText) Nothing -> return () cmdOut "dm-list-done" @@ -952,6 +956,23 @@ cmdDmListContact = do Just to <- contactIdentity <$> getContact cid dmList to +cmdDmListIdentity :: Command +cmdDmListIdentity = do + st <- asks tiStorage + [ tid ] <- asks tiParams + Just ref <- liftIO $ readRef st $ encodeUtf8 tid + Just pid <- return $ validateExtendedIdentity $ wrappedLoad ref + dmList pid + +cmdDmMarkSeen :: Command +cmdDmMarkSeen = do + st <- asks tiStorage + [ tid ] <- asks tiParams + Just ref <- liftIO $ readRef st $ encodeUtf8 tid + Just pid <- return $ validateExtendedIdentity $ wrappedLoad ref + dmMarkAsSeen pid + cmdOut $ unwords [ "dm-mark-seen-done", T.unpack tid ] + cmdChatroomCreate :: Command cmdChatroomCreate = do [name] <- asks tiParams |