diff options
author | joe <joe@jerkface.net> | 2014-03-15 01:11:12 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-03-15 01:11:12 -0400 |
commit | 600a7f5a562357ea30c51ff52f2c2f950afe47f6 (patch) | |
tree | eb36c1054a87416e7842a63134a74a6355d12411 | |
parent | 275dd8db17dbda1acc2967c90f1e70e32fd9a661 (diff) |
lookupLang is now case-insensitive
-rw-r--r-- | Presence/ConsoleWriter.hs | 11 | ||||
-rw-r--r-- | xmppServer.hs | 2 |
2 files changed, 9 insertions, 4 deletions
diff --git a/Presence/ConsoleWriter.hs b/Presence/ConsoleWriter.hs index 6e265e0c..5222258e 100644 --- a/Presence/ConsoleWriter.hs +++ b/Presence/ConsoleWriter.hs | |||
@@ -136,10 +136,15 @@ getPreferedLang = do | |||
136 | return $ lc_all `mplus` lc_messages `mplus` lang | 136 | return $ lc_all `mplus` lc_messages `mplus` lang |
137 | return $ maybe "en" (Text.pack . toBCP47) lang | 137 | return $ maybe "en" (Text.pack . toBCP47) lang |
138 | 138 | ||
139 | cimatch w t = Text.toLower w == Text.toLower t | ||
140 | cimatches w ts = dropWhile (not . cimatch w) ts | ||
141 | |||
139 | -- rfc4647 lookup of best match language tag | 142 | -- rfc4647 lookup of best match language tag |
140 | lookupLang (w:ws) tags | Text.null w = lookupLang ws tags | 143 | lookupLang (w:ws) tags |
141 | | w `elem` tags = Just w | 144 | | Text.null w = lookupLang ws tags |
142 | | otherwise = lookupLang (reduce w:ws) tags | 145 | | otherwise = case cimatches w tags of |
146 | (t:_) -> Just t | ||
147 | [] -> lookupLang (reduce w:ws) tags | ||
143 | where | 148 | where |
144 | reduce w = Text.concat $ reverse nopriv | 149 | reduce w = Text.concat $ reverse nopriv |
145 | where | 150 | where |
diff --git a/xmppServer.hs b/xmppServer.hs index af145906..d5ad7c6a 100644 --- a/xmppServer.hs +++ b/xmppServer.hs | |||
@@ -579,7 +579,7 @@ informPeerPresence state k stanza = do | |||
579 | is_avail <- atomically $ clientIsAvailable client | 579 | is_avail <- atomically $ clientIsAvailable client |
580 | when is_avail $ do | 580 | when is_avail $ do |
581 | putStrLn $ "reversing for client: " ++ show from | 581 | putStrLn $ "reversing for client: " ++ show from |
582 | froms <- do | 582 | froms <- flip (maybe $ return [from]) k . const $ do |
583 | let ClientKey laddr = ck | 583 | let ClientKey laddr = ck |
584 | (_,trip) <- multiplyJIDForClient laddr from | 584 | (_,trip) <- multiplyJIDForClient laddr from |
585 | return (map unsplitJID trip) | 585 | return (map unsplitJID trip) |