mod_roster: Improve readability of bare-JID check
authorKim Alvefur <zash@zash.se>
Wed, 22 Dec 2021 18:07:44 +0100
changeset 12105 7cd94469d15f
parent 12104 0b14b541fd27
child 12106 949c2b52f51e
mod_roster: Improve readability of bare-JID check Silences luacheck too All we care about is that it is a bare JID, not a full JID with a resource, since those are forbidden in rosters.
plugins/mod_roster.lua
--- a/plugins/mod_roster.lua	Wed Dec 22 13:06:32 2021 +0100
+++ b/plugins/mod_roster.lua	Wed Dec 22 18:07:44 2021 +0100
@@ -10,6 +10,7 @@
 local st = require "util.stanza"
 
 local jid_split = require "util.jid".split;
+local jid_resource = require "util.jid".resource;
 local jid_prep = require "util.jid".prep;
 local tonumber = tonumber;
 local pairs = pairs;
@@ -66,8 +67,7 @@
 			local item = query.tags[1];
 			local from_node, from_host = jid_split(stanza.attr.from);
 			local jid = jid_prep(item.attr.jid);
-			local node, host, resource = jid_split(jid);
-			if not resource and host then
+			if jid and not jid_resource(jid) then
 				if jid ~= from_node.."@"..from_host then
 					if item.attr.subscription == "remove" then
 						local roster = session.roster;