~singpolyma/cheogram

bb86cdfcce0db3944ed7eb785a4b43b20d57f264 — Stephen Paul Weber 3 years ago b0343e5
Initiate discover/verify on DM change
1 files changed, 8 insertions(+), 1 deletions(-)

M Main.hs
M Main.hs => Main.hs +8 -1
@@ 1534,9 1534,10 @@ main = do
			void $ runComponent (Server componentJid host (PortNumber $ fromIntegral (read port :: Int))) (fromString secret) $ do
				mapM_ putStanza =<< registerToGateway componentJid gatewayJid (fromString did) (fromString password)
				liftIO $ threadDelay 1000000
		(name:host:port:secret:backendHost:conferences) -> do
		(name:host:port:secret:backendHost:rawdid:conferences) -> do
			log "" "Starting..."
			let Just componentJid = parseJID (fromString name)
			let Just did = normalizeTel (fromString rawdid)
			db <- openTokyoCabinet "./db.tcdb" :: IO TC.HDB
			toJoinPartDebouncer <- atomically newTChan
			sendToComponent <- atomically newTChan


@@ 1563,6 1564,12 @@ main = do
									(atomically . writeTChan sendToComponent . mkStanzaRec =<< unregisterDirectMessageRoute db componentJid userJid existingRoute)

							True <- TC.runTCM $ TC.put db (T.unpack (bareTxt userJid) ++ "\0direct-message-route") (T.unpack $ formatJID gatewayJid)

							forM_ (parseJID $ escapeJid (bareTxt userJid) ++ s"@" ++ formatJID componentJid) $ \from ->
								forM_ (parseJID $ did ++ s"@" ++ formatJID gatewayJid) $ \to ->
									atomically $ writeTChan sendToComponent $ mkStanzaRec $
										mkSMS from to (s"/addjid " ++ bareTxt userJid)

							return ()
						Nothing -> do
							maybeExistingRoute <- (parseJID . fromString =<<) <$> TC.runTCM (TC.get db (T.unpack (bareTxt userJid) ++ "\0direct-message-route"))