+ end -- current policy is to discard headlines if no recipient is available
+ else -- chat or normal message
+ if user then -- some resources are connected
+ local recipients = user.top_resources;
+ if recipients then
+ for i=1,#recipients do
+ recipients[i].send(stanza);
+ end
+ return true;
+ end
+ end
+ -- no resources are online
+ local node, host = jid_split(bare);
+ local ok
+ if user_exists(node, host) then
+ -- TODO apply the default privacy list
+
+ ok = module:fire_event('message/offline/handle', {
+ origin = origin,
+ stanza = stanza,
+ });
+ end
+
+ if not ok then
+ origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));