Mercurial > psgxs
diff psgxs.js @ 34:dcf1f09f8cee
Add message to publish module and various fixes.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 05 Nov 2010 15:31:13 +0100 |
parents | 13011b26181c |
children | 6697f394301f |
line wrap: on
line diff
--- a/psgxs.js +++ b/psgxs.js @@ -88,6 +88,9 @@ function onIq(stanza) { for (var k in modules) { var module = modules[k]; + if (module.stanza && (module.stanza != 'iq')) + continue; + if (module.type && (module.type != type)) continue; @@ -100,7 +103,7 @@ function onIq(stanza) { if (module.number && (module.number != j)) continue; - var toSend = module.func(response, stanza, child2, to); + var toSend = module.func(response, stanza, child2, to, from); if (toSend) { response = toSend; send = true; @@ -112,6 +115,9 @@ function onIq(stanza) { for (var k in modules) { var module = modules[k]; + if (module.stanza && (module.stanza != 'iq')) + continue; + if (module.type && (module.type != type)) continue; @@ -124,7 +130,7 @@ function onIq(stanza) { if (module.number && (module.number != k)) continue; - var toSend = module.func(response, stanza, child1, to); + var toSend = module.func(response, stanza, child1, to, from); if (toSend) { response = toSend; send = true; @@ -148,6 +154,39 @@ function onMessage(stanza) { else response = xmpp.message({to: to, from: from}); + var send = false; + + for (var i in stanza.tags) { + var child = stanza.tags[i]; + for (var k in modules) { + var module = modules[k]; + + if (module.stanza !== 'message') + continue; + + if (module.type && (module.type != type)) + continue; + + if (module.child && (module.child != child.name)) + continue; + + if (module.ns && (module.ns != child.attr.xmlns)) + continue; + + if (module.number && (module.number != k)) + continue; + + var toSend = module.func(response, stanza, child, to, from); + if (toSend) { + response = toSend; + send = true; + delete toSend; + } + } + } + + conn.send(send? response: makeError(response, errors.feature_not_implemented.n)); + var x = stanza.getChild('x', 'jabber:x:data'); if (x) { var form = forms.parse(x);