Software /
code /
prosody-modules
Diff
mod_invites/mod_invites.lua @ 4347:0ec482e617bb
mod_invites: Add public API method for creating group invites
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 17 Jan 2021 17:43:53 +0000 |
parent | 4346:671bc55f0fc9 |
child | 4357:a49ca492e621 |
line wrap: on
line diff
--- a/mod_invites/mod_invites.lua Sun Jan 17 17:42:49 2021 +0000 +++ b/mod_invites/mod_invites.lua Sun Jan 17 17:43:53 2021 +0000 @@ -81,6 +81,21 @@ return create_invite("roster", username.."@"..module.host, allow_registration, additional_data); end +-- Create invitation to register an account and join a user group +-- If explicit ttl is passed, invite is valid for multiple signups +-- during that time period +function create_group(group_id, ttl, additional_data) --luacheck: ignore 131/create_group + local merged_additional_data = { + groups = { group_id }; + }; + if merged_additional_data then + for k, v in pairs(additional_data) do + merged_additional_data[k] = v; + end + end + return create_invite("register", module.host, true, merged_additional_data, ttl, not not ttl); +end + -- Iterates pending (non-expired, unused) invites that allow registration function pending_account_invites() --luacheck: ignore 131/pending_account_invites local store = module:open_store("invite_token");