avoid duplicate srv lookup when testing xmpp
This commit is contained in:
parent
eba9ee5bc6
commit
5a678244e2
1 changed files with 7 additions and 17 deletions
|
@ -187,24 +187,14 @@ jidField = checkBool (isJust . parseJID) bad textField
|
||||||
validateForm :: XMPPForm -> IO (Either SomeException XMPPCreds)
|
validateForm :: XMPPForm -> IO (Either SomeException XMPPCreds)
|
||||||
validateForm f = do
|
validateForm f = do
|
||||||
let jid = fromMaybe (error "bad JID") $ parseJID (formJID f)
|
let jid = fromMaybe (error "bad JID") $ parseJID (formJID f)
|
||||||
let domain = T.unpack $ strDomain $ jidDomain jid
|
|
||||||
hostports <- lookupSRV $ mkSRVTcp "xmpp-client" domain
|
|
||||||
let username = fromMaybe "" (strNode <$> jidNode jid)
|
let username = fromMaybe "" (strNode <$> jidNode jid)
|
||||||
case hostports of
|
testXMPP $ XMPPCreds
|
||||||
((h, PortNumber p):_) -> testXMPP $ XMPPCreds
|
{ xmppUsername = username
|
||||||
{ xmppUsername = username
|
, xmppPassword = formPassword f
|
||||||
, xmppPassword = formPassword f
|
, xmppHostname = T.unpack $ strDomain $ jidDomain jid
|
||||||
, xmppHostname = h
|
, xmppPort = 5222
|
||||||
, xmppPort = fromIntegral p
|
, xmppJID = formJID f
|
||||||
, xmppJID = formJID f
|
}
|
||||||
}
|
|
||||||
_ -> testXMPP $ XMPPCreds
|
|
||||||
{ xmppUsername = username
|
|
||||||
, xmppPassword = formPassword f
|
|
||||||
, xmppHostname = T.unpack $ strDomain $ jidDomain jid
|
|
||||||
, xmppPort = 5222
|
|
||||||
, xmppJID = formJID f
|
|
||||||
}
|
|
||||||
|
|
||||||
testXMPP :: XMPPCreds -> IO (Either SomeException XMPPCreds)
|
testXMPP :: XMPPCreds -> IO (Either SomeException XMPPCreds)
|
||||||
testXMPP creds = either Left (const $ Right creds)
|
testXMPP creds = either Left (const $ Right creds)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue