comparison 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
comparison
equal deleted inserted replaced
33:62cbb1c49bc5 34:dcf1f09f8cee
86 var child2 = child1.tags[j]; 86 var child2 = child1.tags[j];
87 87
88 for (var k in modules) { 88 for (var k in modules) {
89 var module = modules[k]; 89 var module = modules[k];
90 90
91 if (module.stanza && (module.stanza != 'iq'))
92 continue;
93
91 if (module.type && (module.type != type)) 94 if (module.type && (module.type != type))
92 continue; 95 continue;
93 96
94 if (module.child2 && (module.child2 != child2.name)) 97 if (module.child2 && (module.child2 != child2.name))
95 continue; 98 continue;
98 continue; 101 continue;
99 102
100 if (module.number && (module.number != j)) 103 if (module.number && (module.number != j))
101 continue; 104 continue;
102 105
103 var toSend = module.func(response, stanza, child2, to); 106 var toSend = module.func(response, stanza, child2, to, from);
104 if (toSend) { 107 if (toSend) {
105 response = toSend; 108 response = toSend;
106 send = true; 109 send = true;
107 delete toSend; 110 delete toSend;
108 } 111 }
110 } 113 }
111 } else { 114 } else {
112 for (var k in modules) { 115 for (var k in modules) {
113 var module = modules[k]; 116 var module = modules[k];
114 117
118 if (module.stanza && (module.stanza != 'iq'))
119 continue;
120
115 if (module.type && (module.type != type)) 121 if (module.type && (module.type != type))
116 continue; 122 continue;
117 123
118 if (module.child && (module.child != child1.name)) 124 if (module.child && (module.child != child1.name))
119 continue; 125 continue;
122 continue; 128 continue;
123 129
124 if (module.number && (module.number != k)) 130 if (module.number && (module.number != k))
125 continue; 131 continue;
126 132
127 var toSend = module.func(response, stanza, child1, to); 133 var toSend = module.func(response, stanza, child1, to, from);
128 if (toSend) { 134 if (toSend) {
129 response = toSend; 135 response = toSend;
130 send = true; 136 send = true;
131 delete toSend; 137 delete toSend;
132 } 138 }
145 var response; 151 var response;
146 if (id) 152 if (id)
147 response = xmpp.message({to: to, from: from, id: id}); 153 response = xmpp.message({to: to, from: from, id: id});
148 else 154 else
149 response = xmpp.message({to: to, from: from}); 155 response = xmpp.message({to: to, from: from});
156
157 var send = false;
158
159 for (var i in stanza.tags) {
160 var child = stanza.tags[i];
161 for (var k in modules) {
162 var module = modules[k];
163
164 if (module.stanza !== 'message')
165 continue;
166
167 if (module.type && (module.type != type))
168 continue;
169
170 if (module.child && (module.child != child.name))
171 continue;
172
173 if (module.ns && (module.ns != child.attr.xmlns))
174 continue;
175
176 if (module.number && (module.number != k))
177 continue;
178
179 var toSend = module.func(response, stanza, child, to, from);
180 if (toSend) {
181 response = toSend;
182 send = true;
183 delete toSend;
184 }
185 }
186 }
187
188 conn.send(send? response: makeError(response, errors.feature_not_implemented.n));
150 189
151 var x = stanza.getChild('x', 'jabber:x:data'); 190 var x = stanza.getChild('x', 'jabber:x:data');
152 if (x) { 191 if (x) {
153 var form = forms.parse(x); 192 var form = forms.parse(x);
154 if (form.type == 'submit' && form.fields.FORM_TYPE.value == 'subscribe_authorization') { 193 if (form.type == 'submit' && form.fields.FORM_TYPE.value == 'subscribe_authorization') {