Changeset

13740:4cf2caa63277 13.0

mod_invites: Fix traceback when no flags passed
author Matthew Wild <mwild1@gmail.com>
date Mon, 17 Feb 2025 22:57:58 +0000
parents 13738:26a0f653793e
children 13741:e9edf9b50f32
files plugins/mod_invites.lua
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_invites.lua	Mon Feb 17 19:12:40 2025 +0000
+++ b/plugins/mod_invites.lua	Mon Feb 17 22:57:58 2025 +0000
@@ -255,16 +255,16 @@
 
 	handler = function (self, user_jid, opts) --luacheck: ignore 212/self
 		local username = jid_split(user_jid);
-		local roles = opts.role or {};
-		local groups = opts.group or {};
+		local roles = opts and opts.role or {};
+		local groups = opts and opts.group or {};
 
-		if opts.admin then
+		if opts and opts.admin then
 			-- Insert it first since we don't get order out of argparse
 			table.insert(roles, 1, "prosody:admin");
 		end
 
 		local ttl;
-		if opts.expires_after then
+		if opts and opts.expires_after then
 			ttl = human_io.parse_duration(opts.expires_after);
 			if not ttl then
 				return false, "Unable to parse duration: "..opts.expires_after;
@@ -325,13 +325,13 @@
 			return nil, "Supply the JID of the account you want the recipient to become a contact of";
 		end
 		local ttl;
-		if opts.expires_after then
+		if opts and opts.expires_after then
 			ttl = require "prosody.util.human.io".parse_duration(opts.expires_after);
 			if not ttl then
 				return nil, "Unable to parse duration: "..opts.expires_after;
 			end
 		end
-		local invite, err = create_contact(username, opts.allow_registration, nil, ttl);
+		local invite, err = create_contact(username, opts and opts.allow_registration, nil, ttl);
 		if not invite then return nil, err; end
 		return true, invite.landing_page or invite.uri;
 	end;