+function deprecated_warning(f)
+ _G[f] = function(...)
+ log("warn", "Using the global %s() is deprecated, use module:send() or prosody.%s(). %s", f, f, debug.traceback());
+ return prosody[f](...);
+ end
+end
+deprecated_warning"core_post_stanza";
+deprecated_warning"core_process_stanza";
+deprecated_warning"core_route_stanza";
+
+local valid_stanzas = { message = true, presence = true, iq = true };
+local function handle_unhandled_stanza(host, origin, stanza) --luacheck: ignore 212/host
+ local name, xmlns, origin_type = stanza.name, stanza.attr.xmlns or "jabber:client", origin.type;
+ if xmlns == "jabber:client" and valid_stanzas[name] then
+ -- A normal stanza
+ local st_type = stanza.attr.type;
+ if st_type == "error" or (name == "iq" and st_type == "result") then
+ log("debug", "Discarding %s from %s of type: %s", name, origin_type, st_type or '<nil>');
+ return;
+ end
+ if name == "iq" and (st_type == "get" or st_type == "set") and stanza.tags[1] then
+ xmlns = stanza.tags[1].attr.xmlns or "jabber:client";
+ end
+ log("debug", "Unhandled %s stanza: %s; xmlns=%s", origin_type, name, xmlns);
+ if origin.send then
+ origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
+ end
+ else
+ log("warn", "Unhandled %s stream element or stanza: %s; xmlns=%s: %s", origin_type, name, xmlns, tostring(stanza)); -- we didn't handle it
+ origin:close("unsupported-stanza-type");
+ end
+end