- -- Currently we guarantee every stanza to have an xmlns, should we keep this rule?
- if not stanza.attr.xmlns then stanza.attr.xmlns = "jabber:client"; end
-
- -- TODO verify validity of stanza (as well as JID validity)
- if stanza.attr.type == "error" and #stanza.tags == 0 then return; end -- TODO invalid stanza, log
- if stanza.name == "iq" then
- local can_reply = stanza.attr.type == "set" or stanza.attr.type == "get"
- local missing_id = not stanza.attr.id;
- if can_reply and (#stanza.tags ~= 1 or missing_id) then
- origin.send(st.error_reply(stanza, "modify", "bad-request"));
- return;
- elseif missing_id then
+local core_post_stanza, core_process_stanza, core_route_stanza;
+
+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>');