summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Presence/Presence.hs34
1 files changed, 20 insertions, 14 deletions
diff --git a/Presence/Presence.hs b/Presence/Presence.hs
index 9b91dc1d..4cb6266a 100644
--- a/Presence/Presence.hs
+++ b/Presence/Presence.hs
@@ -667,7 +667,8 @@ answerProbe :: PresenceState
667 -> Maybe Text -> ConnectionKey -> TChan Stanza -> IO () 667 -> Maybe Text -> ConnectionKey -> TChan Stanza -> IO ()
668answerProbe state mto k chan = do 668answerProbe state mto k chan = do
669 -- putStrLn $ "answerProbe! " ++ show (stanzaType stanza) 669 -- putStrLn $ "answerProbe! " ++ show (stanzaType stanza)
670 ktc <- atomically $ readTVar (keyToChan state) 670 (ktc,cmap) <- atomically $ (,) <$> readTVar (keyToChan state)
671 <*> readTVar (clients state)
671 muser <- runTraversableT $ do 672 muser <- runTraversableT $ do
672 to <- liftT $ mto 673 to <- liftT $ mto
673 conn <- liftT $ Map.lookup k ktc 674 conn <- liftT $ Map.lookup k ktc
@@ -675,12 +676,13 @@ answerProbe state mto k chan = do
675 -- probes. Is this correct? Check the spec. 676 -- probes. Is this correct? Check the spec.
676 liftMT $ guardPortStrippedAddress h (auxAddr conn) 677 liftMT $ guardPortStrippedAddress h (auxAddr conn)
677 u <- liftT mu 678 u <- liftT mu
678 let ch = addrToText (auxAddr conn) 679 let ch = addrToText (auxAddr conn)
679 return (u,conn,ch) 680 profile = fromMaybe "." $ clientProfile <$> Map.lookup k cmap
681 return (u,profile,conn,ch)
680 682
681 flip (maybe $ return ()) muser $ \(u,conn,ch) -> do 683 flip (maybe $ return ()) muser $ \(u,profile,conn,ch) -> do
682 684
683 resolved_subs <- resolvedFromRoster ConfigFiles.getSubscribers u (_todo {- profile -}) 685 resolved_subs <- resolvedFromRoster ConfigFiles.getSubscribers u profile
684 let gaddrs = groupBy (\a b -> snd a == snd b) (sort resolved_subs) 686 let gaddrs = groupBy (\a b -> snd a == snd b) (sort resolved_subs)
685 whitelist = do 687 whitelist = do
686 xs <- gaddrs 688 xs <- gaddrs
@@ -905,7 +907,8 @@ peerSubscriptionRequest state fail k stanza chan = do
905 (mfrom_u,from_h,_) = splitJID from 907 (mfrom_u,from_h,_) = splitJID from
906 to <- return $ unsplitJID (mto_u,h,Nothing) -- delete resource 908 to <- return $ unsplitJID (mto_u,h,Nothing) -- delete resource
907 from <- return $ unsplitJID (mfrom_u,from_h,Nothing) -- delete resource 909 from <- return $ unsplitJID (mfrom_u,from_h,Nothing) -- delete resource
908 ktc <- atomically . readTVar $ keyToChan state 910 (ktc,cmap) <- atomically $ (,) <$> readTVar (keyToChan state)
911 <*> readTVar (clients state)
909 flip (maybe fail) (Map.lookup k ktc) 912 flip (maybe fail) (Map.lookup k ktc)
910 $ \Conn { auxAddr=laddr } -> do 913 $ \Conn { auxAddr=laddr } -> do
911 (mine,totup) <- rewriteJIDForClient laddr to [] 914 (mine,totup) <- rewriteJIDForClient laddr to []
@@ -913,7 +916,8 @@ peerSubscriptionRequest state fail k stanza chan = do
913 (_,fromtup) <- rewriteJIDForClient laddr from [] 916 (_,fromtup) <- rewriteJIDForClient laddr from []
914 flip (maybe fail) mto_u $ \u -> do 917 flip (maybe fail) mto_u $ \u -> do
915 flip (maybe fail) mfrom_u $ \from_u -> do 918 flip (maybe fail) mfrom_u $ \from_u -> do
916 resolved_subs <- resolvedFromRoster ConfigFiles.getSubscribers u (_todo {- profile -}) 919 let profile = fromMaybe "." $ clientProfile <$> Map.lookup k cmap
920 resolved_subs <- resolvedFromRoster ConfigFiles.getSubscribers u profile
917 let already_subscribed = elem (mfrom_u,k) resolved_subs 921 let already_subscribed = elem (mfrom_u,k) resolved_subs
918 is_wanted = case stanzaType stanza of 922 is_wanted = case stanzaType stanza of
919 PresenceRequestSubscription b -> b 923 PresenceRequestSubscription b -> b
@@ -943,9 +947,9 @@ peerSubscriptionRequest state fail k stanza chan = do
943 947
944 already_pending <- 948 already_pending <-
945 if is_wanted then 949 if is_wanted then
946 addToRosterFile ConfigFiles.modifyPending u (_todo {- profile -}) from' addrs 950 addToRosterFile ConfigFiles.modifyPending u profile from' addrs
947 else do 951 else do
948 removeFromRosterFile ConfigFiles.modifySubscribers u (_todo {- profile -}) from' addrs 952 removeFromRosterFile ConfigFiles.modifySubscribers u profile from' addrs
949 reply <- makeInformSubscription "jabber:server" to from is_wanted 953 reply <- makeInformSubscription "jabber:server" to from is_wanted
950 sendModifiedStanzaToPeer reply chan 954 sendModifiedStanzaToPeer reply chan
951 return False 955 return False
@@ -1037,7 +1041,8 @@ peerInformSubscription state fail k stanza = do
1037 putStrLn $ "TODO: peerInformSubscription" 1041 putStrLn $ "TODO: peerInformSubscription"
1038 -- remove from solicited 1042 -- remove from solicited
1039 flip (maybe fail) (stanzaFrom stanza) $ \from -> do 1043 flip (maybe fail) (stanzaFrom stanza) $ \from -> do
1040 ktc <- atomically $ readTVar (keyToChan state) 1044 (ktc,cmap) <- atomically $ (,) <$> readTVar (keyToChan state)
1045 <*> readTVar (clients state)
1041 flip (maybe fail) (Map.lookup k ktc) 1046 flip (maybe fail) (Map.lookup k ktc)
1042 $ \(Conn { connChan=sender_chan 1047 $ \(Conn { connChan=sender_chan
1043 , auxAddr=laddr }) -> do 1048 , auxAddr=laddr }) -> do
@@ -1052,8 +1057,9 @@ peerInformSubscription state fail k stanza = do
1052 -- This would allow us to answer anonymous probes with 'unsubscribed'. 1057 -- This would allow us to answer anonymous probes with 'unsubscribed'.
1053 flip (maybe fail) muser $ \user -> do 1058 flip (maybe fail) muser $ \user -> do
1054 addrs <- resolvePeer from_h 1059 addrs <- resolvePeer from_h
1055 was_solicited <- removeFromRosterFile ConfigFiles.modifySolicited user (_todo {- profile -}) from'' addrs 1060 let profile = fromMaybe "." $ clientProfile <$> Map.lookup k cmap
1056 subs <- resolvedFromRoster ConfigFiles.getSubscribers user (_todo {- profile -}) 1061 was_solicited <- removeFromRosterFile ConfigFiles.modifySolicited user profile from'' addrs
1062 subs <- resolvedFromRoster ConfigFiles.getSubscribers user profile
1057 let is_sub = not . null $ map ((from_u,) . PeerKey) addrs `intersect` subs 1063 let is_sub = not . null $ map ((from_u,) . PeerKey) addrs `intersect` subs
1058 let (relationship,addf,remf) = 1064 let (relationship,addf,remf) =
1059 case stanzaType stanza of 1065 case stanzaType stanza of
@@ -1066,8 +1072,8 @@ peerInformSubscription state fail k stanza = do
1066 else "none") 1072 else "none")
1067 , ConfigFiles.modifyOthers 1073 , ConfigFiles.modifyOthers
1068 , ConfigFiles.modifyBuddies ) 1074 , ConfigFiles.modifyBuddies )
1069 addToRosterFile addf user (_todo {- profile -}) from'' addrs 1075 addToRosterFile addf user profile from'' addrs
1070 removeFromRosterFile remf user (_todo {- profile -}) from'' addrs 1076 removeFromRosterFile remf user profile from'' addrs
1071 1077
1072 hostname <- textHostName 1078 hostname <- textHostName
1073 let to' = unsplitJID (Just user, hostname, Nothing) 1079 let to' = unsplitJID (Just user, hostname, Nothing)