Software /
code /
verse
File
plugins/legacy.lua @ 445:b119dc4d8bc2
plugins.smacks: Don't warn about zero stanzas acked
It's only if the count somehow goes backwards that something is really
wrong. An ack for zero stanzas is fine and we don't need to do anything.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 10 Jun 2021 11:58:23 +0200 |
parent | 381:65533afab352 |
child | 457:73d4eb93657b |
line wrap: on
line source
local verse = require "verse"; local uuid = require "util.uuid".generate; local xmlns_auth = "jabber:iq:auth"; function verse.plugins.legacy(stream) local function handle_auth_form(result) local query = result:get_child("query", xmlns_auth); if result.attr.type ~= "result" or not query then local type, cond, text = result:get_error(); stream:debug("warn", "%s %s: %s", type, cond, text); --stream:event("authentication-failure", { condition = cond }); -- COMPAT continue anyways end local auth_data = { username = stream.username; password = stream.password; resource = stream.resource or uuid(); digest = false, sequence = false, token = false; }; local request = verse.iq({ to = stream.host, type = "set" }) :tag("query", { xmlns = xmlns_auth }); if #query > 0 then for tag in query:childtags() do local field = tag.name; local value = auth_data[field]; if value then request:tag(field):text(auth_data[field]):up(); elseif value == nil then local cond = "feature-not-implemented"; stream:event("authentication-failure", { condition = cond }); return false; end end else -- COMPAT for servers not following XEP 78 for field, value in pairs(auth_data) do if value then request:tag(field):text(value):up(); end end end stream:send_iq(request, function (response) if response.attr.type == "result" then stream.resource = auth_data.resource; stream.jid = auth_data.username.."@"..stream.host.."/"..auth_data.resource; stream:event("authentication-success"); stream:event("bind-success", stream.jid); else local type, cond, text = response:get_error(); stream:event("authentication-failure", { condition = cond }); end end); end local function handle_opened(attr) if not attr.version then stream:send_iq(verse.iq({type="get"}) :tag("query", { xmlns = "jabber:iq:auth" }) :tag("username"):text(stream.username), handle_auth_form); end end stream:hook("opened", handle_opened); end