208 session.send(stanza); |
208 session.send(stanza); |
209 end |
209 end |
210 end |
210 end |
211 end |
211 end |
212 elseif stanza.name == "message" then -- select a resource to recieve message |
212 elseif stanza.name == "message" then -- select a resource to recieve message |
213 if message.attr.type == 'headline' then |
213 stanza.attr.to = to_bare; |
|
214 if stanza.attr.type == 'headline' then |
214 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 |
215 if session.presence and session.priority >= 0 then |
216 if session.presence and session.priority >= 0 then |
216 stanza.attr.to = session.full_jid; |
|
217 session.send(stanza); |
217 session.send(stanza); |
218 end |
218 end |
219 end |
219 end |
220 else |
220 else |
221 local priority = 0; |
221 local priority = 0; |
257 handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_bare, to_bare, core_route_stanza); |
257 handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_bare, to_bare, core_route_stanza); |
258 else |
258 else |
259 -- TODO send unavailable presence or unsubscribed |
259 -- TODO send unavailable presence or unsubscribed |
260 end |
260 end |
261 elseif stanza.name == "message" then -- FIXME if full jid, then send out to resources with highest priority |
261 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. |
262 if stanza.attr.type == "chat" or stanza.attr.type == "normal" or not stanza.attr.type then |
263 if stanza.attr.type == "chat" or stanza.attr.type == "normal" or not stanza.attr.type then |
263 offlinemanager.store(node, host, stanza); |
264 offlinemanager.store(node, host, stanza); |
264 -- FIXME don't store messages with only chat state notifications |
265 -- FIXME don't store messages with only chat state notifications |
265 end |
266 end |
266 -- TODO allow configuration of offline storage |
267 -- TODO allow configuration of offline storage |