# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1730462845 -3600
# Node ID cc67109ce50273f859ee1d69925f5f5716d7a469
# Parent  006fbd0f0c2f9987d1163f9e4cf2f16a23a9b101
mod_admin_shell: Allow assigning roles to arbitrary JIDs when supported

mod_authz_internal does not support this

diff -r 006fbd0f0c2f -r cc67109ce502 plugins/mod_admin_shell.lua
--- a/plugins/mod_admin_shell.lua	Thu Oct 31 17:18:43 2024 +0100
+++ b/plugins/mod_admin_shell.lua	Fri Nov 01 13:07:25 2024 +0100
@@ -1770,7 +1770,11 @@
 	elseif prosody.hosts[userhost] and not um.user_exists(username, userhost) then
 		return nil, "No such user";
 	end
-	return um.set_user_role(username, host, new_role);
+	if userhost == host then
+		return um.set_user_role(username, userhost, new_role);
+	else
+		return um.set_jid_role(jid, host, new_role);
+	end
 end
 
 describe_command [[user:addrole(jid, host, role) - Add a secondary role to a user]]