From afa09a670b39468687e58fba9b4bfe42afe00223 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 14 Dec 2020 20:20:34 -0500 Subject: [PATCH] Ignore message from ourselves If a message is coming in from our own DID, do not process as that would lead to a loop. --- Main.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Main.hs b/Main.hs index 19cdeba..6634c29 100644 --- a/Main.hs +++ b/Main.hs @@ -1089,7 +1089,7 @@ participantJid payloads = elementChildren =<< isNamed (fromString "{http://jabber.org/protocol/muc#user}x") =<< payloads -component db redis statsd backendHost adhocBotIQReceiver adhocBotMessage toRoomPresences toRejoinManager toJoinPartDebouncer toComponent processDirectMessageRouteConfig jingleHandler componentJid registrationJids conferenceServers = do +component db redis statsd backendHost did adhocBotIQReceiver adhocBotMessage toRoomPresences toRejoinManager toJoinPartDebouncer toComponent processDirectMessageRouteConfig jingleHandler componentJid registrationJids conferenceServers = do thread <- forkXMPP $ forever $ flip catchError (log "component EXCEPTION") $ do stanza <- liftIO $ atomically $ readTChan toComponent @@ -1175,7 +1175,8 @@ component db redis statsd backendHost adhocBotIQReceiver adhocBotMessage toRoomP log "backend error" stanza (ReceivedMessage m) | Just txt <- getBody "jabber:component:accept" m, - Just cheoJid <- mapToComponent from -> + Just cheoJid <- mapToComponent from, + fmap strNode (jidNode from) /= Just did -> mapM_ sendToComponent =<< processSMS db componentJid conferenceServers from cheoJid txt _ -> log "backend no match" stanza (Just from, Just to, Nothing, Just localpart, ReceivedMessage m) @@ -2038,5 +2039,5 @@ main = do (log "runComponent ENDED" <=< (runExceptT . syncIO)) $ runComponent (Server componentJid host (PortNumber port)) secret - (component db redis statsd backendHost adhocBotIQReceiver (writeTChan adhocBotMessages) toRoomPresences toRejoinManager toJoinPartDebouncer sendToComponent processDirectMessageRouteConfig jingleHandler componentJid [registrationJid] conferences) + (component db redis statsd backendHost did adhocBotIQReceiver (writeTChan adhocBotMessages) toRoomPresences toRejoinManager toJoinPartDebouncer sendToComponent processDirectMessageRouteConfig jingleHandler componentJid [registrationJid] conferences) _ -> log "ERROR" "Bad arguments" -- 2.45.2