# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1680869004 -7200
# Node ID 8128c4f1b08b6fb96873ab9512c0d41ed1e788de
# Parent  585bd71a1a972fb64693b9876f810bb7a7626c31
mod_admin_shell: Allow "*" as substitute for 'nil' for easier CLI usage

Since prosodyctl shell with additional arguments assumes the first two
are a section:command() and any following arguments are strings, passing
a bare 'nil' is not possible. In order to avoid delving into this rabbit
hole, instead produce a token that alone is not really a legal JID for
use as wildcard.

diff -r 585bd71a1a97 -r 8128c4f1b08b plugins/mod_admin_shell.lua
--- a/plugins/mod_admin_shell.lua	Fri Apr 07 13:58:39 2023 +0200
+++ b/plugins/mod_admin_shell.lua	Fri Apr 07 14:03:24 2023 +0200
@@ -1017,7 +1017,7 @@
 
 	local function match(session)
 		local jid = get_jid(session)
-		return (not match_jid) or jid_compare(jid, match_jid);
+		return (not match_jid) or match_jid == "*" or jid_compare(jid, match_jid);
 	end
 
 	local group_by_host = true;
@@ -1100,7 +1100,7 @@
 
 	local function match(session)
 		local host, remote = get_s2s_hosts(session);
-		return not match_jid or host == match_jid or remote == match_jid;
+		return not match_jid or match_jid == "*" or host == match_jid or remote == match_jid;
 	end
 
 	local group_by_host = true;