diff options
author | joe <joe@jerkface.net> | 2017-10-27 20:24:23 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-10-27 20:24:23 -0400 |
commit | e864406381f10370907afaa1054dcd4370466bf3 (patch) | |
tree | 7270b4ea15f32a9963bf4ab2c749947d3d76d15c | |
parent | 50584cc471da1000a90e340377b71619b74c6b60 (diff) |
Show Friend requests.
-rw-r--r-- | examples/dhtd.hs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 9966fb32..4d9072b5 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -46,6 +46,8 @@ import GHC.Conc (labelThread) | |||
46 | #endif | 46 | #endif |
47 | import qualified Data.HashMap.Strict as HashMap | 47 | import qualified Data.HashMap.Strict as HashMap |
48 | import qualified Data.Vector as V | 48 | import qualified Data.Vector as V |
49 | import qualified Data.Text as T | ||
50 | import qualified Data.Text.Encoding as T | ||
49 | 51 | ||
50 | import Crypto.Tox -- (zeros32,SecretKey,PublicKey, generateSecretKey, toPublic, encodeSecret, decodeSecret, userKeys) | 52 | import Crypto.Tox -- (zeros32,SecretKey,PublicKey, generateSecretKey, toPublic, encodeSecret, decodeSecret, userKeys) |
51 | import Network.UPNP as UPNP | 53 | import Network.UPNP as UPNP |
@@ -450,7 +452,17 @@ clientSession s@Session{..} sock cnum h = do | |||
450 | forM pairs $ \(_,pk) -> delRoster roster pk | 452 | forM pairs $ \(_,pk) -> delRoster roster pk |
451 | readTVar userkeys | 453 | readTVar userkeys |
452 | hPutClient h . showReport $ map mkrow ks | 454 | hPutClient h . showReport $ map mkrow ks |
453 | ("roster", s) -> cmd0 $ atomically (dnsPresentation roster) >>= hPutClient h | 455 | ("roster", s) -> cmd0 $ join $ atomically $ do |
456 | dns <- dnsPresentation roster | ||
457 | fs <- HashMap.toList <$> friendRequests roster | ||
458 | let showFriend (remotekey,fr) = | ||
459 | (" " ++ show remotekey, T.unpack $ T.decodeUtf8 $ Tox.friendRequestText fr) | ||
460 | showAccount (me,cs) = | ||
461 | [(show me,"")] ++ map showFriend cs | ||
462 | frs = fs >>= showAccount | ||
463 | return $ do | ||
464 | hPutClientChunk h $ unlines [ dns, "", "Friend Requests" ] | ||
465 | hPutClient h $ showReport frs | ||
454 | ("g", s) | Just DHT{..} <- Map.lookup netname dhts | 466 | ("g", s) | Just DHT{..} <- Map.lookup netname dhts |
455 | -> cmd0 $ do | 467 | -> cmd0 $ do |
456 | -- arguments: method | 468 | -- arguments: method |