Software /
code /
prosody
Comparison
plugins/mod_invites.lua @ 13410:7efdd143fdfc
mod_invites: Allow specifying invite ttl on command line
Was missing a way to pass TTL via command or shell.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 13 Jan 2024 10:58:12 +0100 |
parent | 13355:a6c8a50cdfb5 |
child | 13411:d815882d2692 |
comparison
equal
deleted
inserted
replaced
13409:95d8875c90dc | 13410:7efdd143fdfc |
---|---|
2 local it = require "prosody.util.iterators"; | 2 local it = require "prosody.util.iterators"; |
3 local url = require "socket.url"; | 3 local url = require "socket.url"; |
4 local jid_node = require "prosody.util.jid".node; | 4 local jid_node = require "prosody.util.jid".node; |
5 local jid_split = require "prosody.util.jid".split; | 5 local jid_split = require "prosody.util.jid".split; |
6 local argparse = require "prosody.util.argparse"; | 6 local argparse = require "prosody.util.argparse"; |
7 local human_io = require "prosody.util.human.io"; | |
7 | 8 |
8 local default_ttl = module:get_option_period("invite_expiry", "1 week"); | 9 local default_ttl = module:get_option_period("invite_expiry", "1 week"); |
9 | 10 |
10 local token_storage; | 11 local token_storage; |
11 if prosody.process_type == "prosody" or prosody.shutdown then | 12 if prosody.process_type == "prosody" or prosody.shutdown then |
281 print(" --admin Make the new user privileged") | 282 print(" --admin Make the new user privileged") |
282 print(" Equivalent to --role prosody:admin") | 283 print(" Equivalent to --role prosody:admin") |
283 print(" --role ROLE Grant the given ROLE to the new user") | 284 print(" --role ROLE Grant the given ROLE to the new user") |
284 print(" --group GROUPID Add the user to the group with the given ID") | 285 print(" --group GROUPID Add the user to the group with the given ID") |
285 print(" Can be specified multiple times") | 286 print(" Can be specified multiple times") |
287 print(" --expires-after T Time until the invite expires (e.g. '1 week')") | |
286 print() | 288 print() |
287 print("--group can be specified multiple times; the user will be added to all groups.") | 289 print("--group can be specified multiple times; the user will be added to all groups.") |
288 print() | 290 print() |
289 print("--reset and the other options cannot be mixed.") | 291 print("--reset and the other options cannot be mixed.") |
290 return 2 | 292 return 2 |
330 invite = assert(invites.create_account_reset(allow_reset)); | 332 invite = assert(invites.create_account_reset(allow_reset)); |
331 else | 333 else |
332 invite = assert(invites.create_account(nil, { | 334 invite = assert(invites.create_account(nil, { |
333 roles = roles, | 335 roles = roles, |
334 groups = groups | 336 groups = groups |
335 })); | 337 }, opts.expires_after and human_io.parse_duration(opts.expires_after))); |
336 end | 338 end |
337 | 339 |
338 print(invite.landing_page or invite.uri); | 340 print(invite.landing_page or invite.uri); |
339 end | 341 end |