8 -- Handle stanzas that were addressed to the server (whether they came from c2s, s2s, etc.) |
8 -- Handle stanzas that were addressed to the server (whether they came from c2s, s2s, etc.) |
9 function handle_stanza(origin, stanza) |
9 function handle_stanza(origin, stanza) |
10 -- Use plugins |
10 -- Use plugins |
11 if not modulemanager.handle_stanza(origin, stanza) then |
11 if not modulemanager.handle_stanza(origin, stanza) then |
12 if stanza.name == "iq" then |
12 if stanza.name == "iq" then |
13 local reply = st.reply(stanza); |
13 if stanza.attr.type ~= "result" and stanza.attr.type ~= "error" then |
14 reply.attr.type = "error"; |
14 send(origin, st.error_reply(stanza, "cancel", "service-unavailable")); |
15 reply:tag("error", { type = "cancel" }) |
15 end |
16 :tag("service-unavailable", { xmlns = xmlns_stanzas }); |
16 elseif stanza.name == "message" then |
17 send(origin, reply); |
17 send(origin, st.error_reply(stanza, "cancel", "service-unavailable")); |
|
18 elseif stanza.name ~= "presence" then |
|
19 error("Unknown stanza"); |
18 end |
20 end |
19 end |
21 end |
20 end |
22 end |