Comparison

core/stanza_router.lua @ 862:b3b80ccddb0c

Merged with main tip.
author Tobias Markmann <tm@ayena.de>
date Tue, 03 Mar 2009 17:48:04 +0100
parent 854:b9cfc9d5496a
child 894:b61c3589cd7b
child 896:2c0b9e3c11c3
comparison
equal deleted inserted replaced
861:2a5373897128 862:b3b80ccddb0c
215 for _, session in pairs(user.sessions) do -- find resource with greatest priority 215 for _, session in pairs(user.sessions) do -- find resource with greatest priority
216 if session.presence and session.priority >= 0 then 216 if session.presence and session.priority >= 0 then
217 session.send(stanza); 217 session.send(stanza);
218 end 218 end
219 end 219 end
220 elseif resource and stanza.attr.type == 'groupchat' then
221 -- Groupchat message sent to offline resource
222 origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
220 else 223 else
221 local priority = 0; 224 local priority = 0;
222 local recipients = {}; 225 local recipients = {};
223 for _, session in pairs(user.sessions) do -- find resource with greatest priority 226 for _, session in pairs(user.sessions) do -- find resource with greatest priority
224 if session.presence then 227 if session.presence then
261 elseif stanza.name == "message" then -- FIXME if full jid, then send out to resources with highest priority 264 elseif stanza.name == "message" then -- FIXME if full jid, then send out to resources with highest priority
262 stanza.attr.to = to_bare; -- TODO not in RFC, but seems obvious. Should discuss on the mailing list. 265 stanza.attr.to = to_bare; -- TODO not in RFC, but seems obvious. Should discuss on the mailing list.
263 if stanza.attr.type == "chat" or stanza.attr.type == "normal" or not stanza.attr.type then 266 if stanza.attr.type == "chat" or stanza.attr.type == "normal" or not stanza.attr.type then
264 offlinemanager.store(node, host, stanza); 267 offlinemanager.store(node, host, stanza);
265 -- FIXME don't store messages with only chat state notifications 268 -- FIXME don't store messages with only chat state notifications
269 elseif stanza.attr.type == "groupchat" then
270 local reply = st.error_reply(stanza, "cancel", "service-unavailable");
271 reply.attr.from = to;
272 origin.send(reply);
266 end 273 end
267 -- TODO allow configuration of offline storage 274 -- TODO allow configuration of offline storage
268 -- TODO send error if not storing offline 275 -- TODO send error if not storing offline
269 elseif stanza.name == "iq" then 276 elseif stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then
270 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); 277 origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
271 end 278 end
272 else -- user does not exist 279 else -- user does not exist
273 -- TODO we would get here for nodeless JIDs too. Do something fun maybe? Echo service? Let plugins use xmpp:server/resource addresses? 280 -- TODO we would get here for nodeless JIDs too. Do something fun maybe? Echo service? Let plugins use xmpp:server/resource addresses?
274 if stanza.name == "presence" then 281 if stanza.name == "presence" then
275 local t = stanza.attr.type; 282 local t = stanza.attr.type;
276 if t == "subscribe" or t == "probe" then 283 if t == "subscribe" or t == "probe" then
277 origin.send(st.presence({from = to_bare, to = from_bare, type = "unsubscribed"})); 284 origin.send(st.presence({from = to_bare, to = from_bare, type = "unsubscribed"}));
278 end 285 end
279 -- else ignore 286 -- else ignore
280 else 287 elseif stanza.attr.type ~= "error" and (stanza.name ~= "iq" or stanza.attr.type ~= "result") then
281 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); 288 origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
282 end 289 end
283 end 290 end
284 end 291 end
285 elseif origin.type == "c2s" then 292 elseif origin.type == "c2s" then