Software /
code /
prosody
Comparison
plugins/mod_invites.lua @ 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 |
parent | 13738:26a0f653793e |
child | 13741:e9edf9b50f32 |
comparison
equal
deleted
inserted
replaced
13738:26a0f653793e | 13740:4cf2caa63277 |
---|---|
253 value_params = { expires_after = true }; | 253 value_params = { expires_after = true }; |
254 }; | 254 }; |
255 | 255 |
256 handler = function (self, user_jid, opts) --luacheck: ignore 212/self | 256 handler = function (self, user_jid, opts) --luacheck: ignore 212/self |
257 local username = jid_split(user_jid); | 257 local username = jid_split(user_jid); |
258 local roles = opts.role or {}; | 258 local roles = opts and opts.role or {}; |
259 local groups = opts.group or {}; | 259 local groups = opts and opts.group or {}; |
260 | 260 |
261 if opts.admin then | 261 if opts and opts.admin then |
262 -- Insert it first since we don't get order out of argparse | 262 -- Insert it first since we don't get order out of argparse |
263 table.insert(roles, 1, "prosody:admin"); | 263 table.insert(roles, 1, "prosody:admin"); |
264 end | 264 end |
265 | 265 |
266 local ttl; | 266 local ttl; |
267 if opts.expires_after then | 267 if opts and opts.expires_after then |
268 ttl = human_io.parse_duration(opts.expires_after); | 268 ttl = human_io.parse_duration(opts.expires_after); |
269 if not ttl then | 269 if not ttl then |
270 return false, "Unable to parse duration: "..opts.expires_after; | 270 return false, "Unable to parse duration: "..opts.expires_after; |
271 end | 271 end |
272 end | 272 end |
323 local username = jid_split(user_jid); | 323 local username = jid_split(user_jid); |
324 if not username then | 324 if not username then |
325 return nil, "Supply the JID of the account you want the recipient to become a contact of"; | 325 return nil, "Supply the JID of the account you want the recipient to become a contact of"; |
326 end | 326 end |
327 local ttl; | 327 local ttl; |
328 if opts.expires_after then | 328 if opts and opts.expires_after then |
329 ttl = require "prosody.util.human.io".parse_duration(opts.expires_after); | 329 ttl = require "prosody.util.human.io".parse_duration(opts.expires_after); |
330 if not ttl then | 330 if not ttl then |
331 return nil, "Unable to parse duration: "..opts.expires_after; | 331 return nil, "Unable to parse duration: "..opts.expires_after; |
332 end | 332 end |
333 end | 333 end |
334 local invite, err = create_contact(username, opts.allow_registration, nil, ttl); | 334 local invite, err = create_contact(username, opts and opts.allow_registration, nil, ttl); |
335 if not invite then return nil, err; end | 335 if not invite then return nil, err; end |
336 return true, invite.landing_page or invite.uri; | 336 return true, invite.landing_page or invite.uri; |
337 end; | 337 end; |
338 }); | 338 }); |
339 | 339 |