comparison plugins/mod_invites.lua @ 14083:486d42764da9

mod_invites: Allow specifying --reusable for invites created via shell commands
author Matthew Wild <mwild1@gmail.com>
date Mon, 16 Feb 2026 17:56:02 +0000
parents 13b3220c3282
children 414e731b5972
comparison
equal deleted inserted replaced
14082:13b3220c3282 14083:486d42764da9
259 }; 259 };
260 host_selector = "user_jid"; 260 host_selector = "user_jid";
261 flags = { 261 flags = {
262 array_params = { role = true, group = have_group_invites }; 262 array_params = { role = true, group = have_group_invites };
263 value_params = { expires_after = true }; 263 value_params = { expires_after = true };
264 bool_params = { admin = true }; 264 bool_params = { admin = true, reusable = true };
265 }; 265 };
266 266
267 handler = function (self, user_jid, opts) --luacheck: ignore 212/self 267 handler = function (self, user_jid, opts) --luacheck: ignore 212/self
268 local username = jid_split(user_jid); 268 local username = jid_split(user_jid);
269 local roles = opts and opts.role or {}; 269 local roles = opts and opts.role or {};
283 end 283 end
284 284
285 local invite = assert(create_account(username, { 285 local invite = assert(create_account(username, {
286 roles = roles; 286 roles = roles;
287 groups = groups; 287 groups = groups;
288 }, ttl)); 288 }, ttl, opts.reusable));
289 289
290 return true, invite.landing_page or invite.uri; 290 return true, invite.landing_page or invite.uri;
291 end; 291 end;
292 }); 292 });
293 293
328 desc = "Create an invitation to become contacts with the specified user"; 328 desc = "Create an invitation to become contacts with the specified user";
329 args = { { name = "user_jid", type = "string" } }; 329 args = { { name = "user_jid", type = "string" } };
330 host_selector = "user_jid"; 330 host_selector = "user_jid";
331 flags = { 331 flags = {
332 value_params = { expires_after = true }; 332 value_params = { expires_after = true };
333 bool_params = { allow_registration = true }; 333 bool_params = { allow_registration = true, reusable = true };
334 }; 334 };
335 335
336 handler = function (self, user_jid, opts) --luacheck: ignore 212/self 336 handler = function (self, user_jid, opts) --luacheck: ignore 212/self
337 local username = jid_split(user_jid); 337 local username = jid_split(user_jid);
338 if not username then 338 if not username then
343 ttl = require "prosody.util.human.io".parse_duration(opts.expires_after); 343 ttl = require "prosody.util.human.io".parse_duration(opts.expires_after);
344 if not ttl then 344 if not ttl then
345 return nil, "Unable to parse duration: "..opts.expires_after; 345 return nil, "Unable to parse duration: "..opts.expires_after;
346 end 346 end
347 end 347 end
348 local invite, err = create_contact(username, opts and opts.allow_registration, nil, ttl); 348 local invite, err = create_contact(username, opts and opts.allow_registration, nil, ttl, opts.reusable);
349 if not invite then return nil, err; end 349 if not invite then return nil, err; end
350 return true, invite.landing_page or invite.uri; 350 return true, invite.landing_page or invite.uri;
351 end; 351 end;
352 }); 352 });
353 353