~singpolyma/cheogram-sip

c3560dcbb8cbbeb7d8de8c0760208969a2e648d9 — Stephen Paul Weber 4 months ago 12ef4e7
Make redis optional
1 files changed, 9 insertions(+), 3 deletions(-)

M gateway.hs
M gateway.hs => gateway.hs +9 -3
@@ 194,9 194,13 @@ main = do
	let Just componentJid = XMPP.parseJID componentJidTxt
	let port = read portTxt
	let server = XMPP.Server componentJid (textToString host) port
	let Right redisConnectInfo = RedisURL.parseConnectInfo $ textToString redisURL

	redis <- Redis.checkedConnect redisConnectInfo
	mredis <- case RedisURL.parseConnectInfo $ textToString redisURL of
	  Right redisConnectInfo -> fmap Just $ Redis.checkedConnect redisConnectInfo
	  Left _ -> do
	    print "No valid Redis specified, skiping..."
	    return Nothing

	sessionInitiates <- Cache.newCache (Just $ TimeSpec 900 0)
	fullJids <- Cache.newCache (Just $ TimeSpec 900 0)
	-- exceptT print return $ runRoutedComponent server secret $ do


@@ 212,7 216,9 @@ main = do
					let Just (to, from) = asteriskToReal componentJid $ receivedTo stanza
					liftIO $ Cache.purgeExpired sessionInitiates

					mostAvailable <- liftIO $ Redis.runRedis redis $ do
					mostAvailable <- case mredis of
					  Nothing -> return Nothing
					  Just redis -> liftIO $ Redis.runRedis redis $ do
						Right resources <- Redis.hgetall (encodeUtf8 $ bareTxt to)
						jingleMessage <- anyM (fmap (fromRight False) . flip Redis.sismember (s"urn:xmpp:jingle-message:0")) $ map (B.drop 2 . snd) resources
						-- TODO: check if mostAvailable supports jingle audio. really we want most available that does