diff options
author | joe <joe@jerkface.net> | 2018-06-25 07:33:47 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2018-06-25 16:42:20 -0400 |
commit | d1e0191f6ea329ba2ffbc1b99fd41b5aec68765b (patch) | |
tree | 378796f0e1ed4a3914f11aec45d5e05e2bf6c011 /ToxManager.hs | |
parent | fab0ea6ff17b2109b20ebffcef9262b1684203ca (diff) |
Forward instant messages from XMPP clients to Tox peers.
Diffstat (limited to 'ToxManager.hs')
-rw-r--r-- | ToxManager.hs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/ToxManager.hs b/ToxManager.hs index d16a5d2e..6d0149cf 100644 --- a/ToxManager.hs +++ b/ToxManager.hs | |||
@@ -26,7 +26,7 @@ import qualified Network.Tox.Onion.Transport as Tox | |||
26 | import Presence | 26 | import Presence |
27 | import Text.Read | 27 | import Text.Read |
28 | import ToxToXMPP | 28 | import ToxToXMPP |
29 | import XMPPServer (ClientAddress) | 29 | import XMPPServer |
30 | import DPut | 30 | import DPut |
31 | 31 | ||
32 | 32 | ||
@@ -140,5 +140,17 @@ toxman announcer toxbkts tox presence = ToxManager | |||
140 | Just acc -> setContactPolicy (Tox.id2key themid) TryingToConnect acc | 140 | Just acc -> setContactPolicy (Tox.id2key themid) TryingToConnect acc |
141 | -- If unscheduled and unconnected, schedule recurring search for this contact. | 141 | -- If unscheduled and unconnected, schedule recurring search for this contact. |
142 | _ -> return () -- Remove contact. | 142 | _ -> return () -- Remove contact. |
143 | , resolveToxPeer = \me them -> do | ||
144 | let lookupContact accs | ||
145 | = do meid <- readMaybe $ T.unpack me | ||
146 | themid <- readMaybe $ T.unpack them | ||
147 | acc <- HashMap.lookup meid accs | ||
148 | return $ HashMap.lookup themid <$> readTVar (contacts acc) | ||
149 | atomically $ do | ||
150 | accs <- let ContactInfo{ accounts } = Tox.toxContactInfo tox | ||
151 | in readTVar accounts | ||
152 | mc <- join <$> sequence (lookupContact accs) | ||
153 | maddr <- join <$> mapM (readTVar . contactLastSeenAddr) mc | ||
154 | return $ addrToPeerKey . Remote . Tox.nodeAddr . snd <$> maddr | ||
143 | } | 155 | } |
144 | 156 | ||