git » sdk » commit 7b6867e

Do not process MAM messages in main message handle

author Stephen Paul Weber
2024-11-18 22:04:35 UTC
committer Stephen Paul Weber
2024-11-18 22:04:35 UTC
parent 71f1dea234bdb3f368b8c5089061dc89c4a32672

Do not process MAM messages in main message handle

Since all handlers get called for every stanza, even though the
MessageSync object has its own handler, this event still fires, but we
want to do as little work as possible and bail out since we know it's
being handled elsewhere.

snikket/Client.hx +6 -0

diff --git a/snikket/Client.hx b/snikket/Client.hx
index 28870b3..840912b 100644
--- a/snikket/Client.hx
+++ b/snikket/Client.hx
@@ -135,6 +135,12 @@ class Client extends EventEmitter {
 
 		stream.on("message", function(event) {
 			final stanza:Stanza = event.stanza;
+
+			if (stanza.getChild("result", "urn:xmpp:mam:2") != null) {
+				// We don't want to process MAM messages here
+				return EventUnhandled;
+			}
+
 			final from = stanza.attr.get("from") == null ? null : JID.parse(stanza.attr.get("from"));
 
 			if (stanza.attr.get("type") == "error" && from != null) {